cement.core.arg
Cement core argument module.
- class cement.core.arg.ArgumentHandler(**kw: Any)[source]
Bases:
ArgumentInterface
,Handler
Argument handler implementation
- class cement.core.arg.ArgumentInterface(**kw: Any)[source]
Bases:
Interface
This class defines the Argument Interface. Handlers that implement this interface must provide the methods and attributes defined below. In general, most implementations should sub-class from the provided
ArgumentHandler
base class as a starting point.- abstract add_argument(*args: str, **kw: Any) None [source]
Add arguments to the parser.
This should be
-o/--option
or positional. Note that the interface defines the following parameters so that at the very least, external extensions can guarantee that they can properly add command line arguments when necessary. The implementation itself should, and will provide and support many more options than those listed here. That said, the implementation must support the following:- Parameters:
args (list) – List of option arguments. Generally something like
['-h', '--help']
.- Keyword Arguments:
dest (str) – The destination name (variable). Default: args[0]
help (str) – The help text for
--help
output (for that argument).action (str) – Must support:
['store', 'store_true', 'store_false', 'store_const']
choices (list) – A list of valid values that can be passed to an option whose action is
store
.const (str) – The value stored if
action == 'store_const'
.default (str) – The default value.
- Returns:
None
- abstract parse(*args: List[str]) object [source]
Parse the argument list (i.e.
sys.argv
). Can return any object as long as its’ members contain those of the added arguments. For example, if adding a-v/--version
option that stores to the dest ofversion
, then the member must be callable asObject().version
.