argument
¶
-
class
invoke.parser.argument.
Argument
(name=None, names=(), kind=<type 'str'>, default=None, help=None, positional=False, optional=False, attr_name=None)¶ A command-line argument/flag.
Parameters: - name – Syntactic sugar for
names=[<name>]
. Giving bothname
andnames
is invalid. - names – List of valid identifiers for this argument. For example, a “help”
argument may be defined with a name list of
['-h', '--help']
. - kind – Type factory & parser hint. E.g.
int
will turn the default text value parsed, into a Python integer; andbool
will tell the parser not to expect an actual value but to treat the argument as a toggle/flag. - default – Default value made available to the parser if no value is given on the command line.
- help – Help text, intended for use with
--help
. - positional – Whether or not this argument’s value may be given positionally. When
False
(default) arguments must be explicitly named. - optional – Whether or not this (non-
bool
) argument requires a value. - attr_name – A Python identifier/attribute friendly name, typically filled in with
the underscored version when
name
/names
contain dashes.
-
__weakref__
¶ list of weak references to the object (if defined)
-
name
¶ The canonical attribute-friendly name for this argument.
Will be
attr_name
(if given to constructor) or the first name innames
otherwise.
-
set_value
(value, cast=True)¶ Actual explicit value-setting API call.
Sets
self.raw_value
tovalue
directly.Sets
self.value
toself.kind(value)
, unlesscast=False
in which case the raw value is also used.
- name – Syntactic sugar for