Cement core argument module.

class cement.core.arg.ArgumentHandler(**kw)[source]

Bases: ArgumentInterface, Handler

Argument handler implementation

class cement.core.arg.ArgumentInterface(**kw)[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.

class Meta[source]

Bases: object

Interface meta-data options.

interface = 'argument'

The string identifier of the interface.

abstract add_argument(*args, **kw)[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:


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.



abstract parse(*args)[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 of version, then the member must be callable as Object().version.


args (list) – A list of command line arguments


A callable object whose member reprisent the available arguments

Return type: