class Argument: (source)
A command-line argument/flag. :param name: Syntactic sugar for ``names=[<name>]``. Giving both ``name`` and ``names`` is invalid. :param names: List of valid identifiers for this argument. For example, a "help" argument may be defined with a name list of ``['-h', '--help']``. :param kind: Type factory & parser hint. E.g. ``int`` will turn the default text value parsed, into a Python integer; and ``bool`` will tell the parser not to expect an actual value but to treat the argument as a toggle/flag. :param default: Default value made available to the parser if no value is given on the command line. :param help: Help text, intended for use with ``--help``. :param positional: Whether or not this argument's value may be given positionally. When ``False`` (default) arguments must be explicitly named. :param optional: Whether or not this (non-``bool``) argument requires a value. :param incrementable: Whether or not this (``int``) argument is to be incremented instead of overwritten/assigned to. :param attr_name: A Python identifier/attribute friendly name, typically filled in with the underscored version when ``name``/``names`` contain dashes. .. versionadded:: 1.0
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | set |
Actual explicit value-setting API call. |
Method | value |
Undocumented |
Instance Variable | attr |
Undocumented |
Instance Variable | default |
Undocumented |
Instance Variable | help |
Undocumented |
Instance Variable | incrementable |
Undocumented |
Instance Variable | kind |
Undocumented |
Instance Variable | names |
Undocumented |
Instance Variable | optional |
Undocumented |
Instance Variable | positional |
Undocumented |
Instance Variable | raw |
Undocumented |
Property | got |
Returns whether the argument was ever given a (non-default) value. |
Property | name |
The canonical attribute-friendly name for this argument. |
Property | nicknames |
Undocumented |
Property | takes |
Undocumented |
Property | value |
Undocumented |
Instance Variable | _value |
Undocumented |
Undocumented
Actual explicit value-setting API call. Sets ``self.raw_value`` to ``value`` directly. Sets ``self.value`` to ``self.kind(value)``, unless: - ``cast=False``, in which case the raw value is also used. - ``self.kind==list``, in which case the value is appended to ``self.value`` instead of cast & overwritten. - ``self.incrementable==True``, in which case the value is ignored and the current (assumed int) value is simply incremented. .. versionadded:: 1.0
Returns whether the argument was ever given a (non-default) value. For most argument kinds, this simply checks whether the internally stored value is non-``None``; for others, such as ``list`` kinds, different checks may be used. .. versionadded:: 1.3