MCPcopy Index your code
hub / github.com/pyinvoke/invoke / Argument

Class Argument

invoke/parser/argument.py:7–178  ·  view source on GitHub ↗

A command-line argument/flag. :param name: Syntactic sugar for ``names=[ ]``. 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

Source from the content-addressed store, hash-verified

5
6
7class Argument:
8 """
9 A command-line argument/flag.
10
11 :param name:
12 Syntactic sugar for ``names=[<name>]``. Giving both ``name`` and
13 ``names`` is invalid.
14 :param names:
15 List of valid identifiers for this argument. For example, a "help"
16 argument may be defined with a name list of ``['-h', '--help']``.
17 :param kind:
18 Type factory & parser hint. E.g. ``int`` will turn the default text
19 value parsed, into a Python integer; and ``bool`` will tell the
20 parser not to expect an actual value but to treat the argument as a
21 toggle/flag.
22 :param default:
23 Default value made available to the parser if no value is given on the
24 command line.
25 :param help:
26 Help text, intended for use with ``--help``.
27 :param positional:
28 Whether or not this argument&#x27;s value may be given positionally. When
29 ``False`` (default) arguments must be explicitly named.
30 :param optional:
31 Whether or not this (non-``bool``) argument requires a value.
32 :param incrementable:
33 Whether or not this (``int``) argument is to be incremented instead of
34 overwritten/assigned to.
35 :param attr_name:
36 A Python identifier/attribute friendly name, typically filled in with
37 the underscored version when ``name``/``names`` contain dashes.
38
39 .. versionadded:: 1.0
40 """
41
42 def __init__(
43 self,
44 name: Optional[str] = None,
45 names: Iterable[str] = (),
46 kind: Any = str,
47 default: Optional[Any] = None,
48 help: Optional[str] = None,
49 positional: bool = False,
50 optional: bool = False,
51 incrementable: bool = False,
52 attr_name: Optional[str] = None,
53 ) -> None:
54 if name and names:
55 raise TypeError(
56 "Cannot give both 'name' and 'names' arguments! Pick one."
57 )
58 if not (name or names):
59 raise TypeError("An Argument must have at least one name.")
60 if names:
61 self.names = tuple(names)
62 elif name and not names:
63 self.names = (name,)
64 self.kind = kind

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…