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

Method __init__

invoke/parser/context.py:71–98  ·  view source on GitHub ↗

Create a new ``ParserContext`` named ``name``, with ``aliases``. ``name`` is optional, and should be a string if given. It's used to tell ParserContext objects apart, and for use in a Parser when determining what chunk of input might belong to a given ParserContext.

(
        self,
        name: Optional[str] = None,
        aliases: Iterable[str] = (),
        args: Iterable[Argument] = (),
    )

Source from the content-addressed store, hash-verified

69 """
70
71 def __init__(
72 self,
73 name: Optional[str] = None,
74 aliases: Iterable[str] = (),
75 args: Iterable[Argument] = (),
76 ) -> None:
77 """
78 Create a new ``ParserContext`` named ``name``, with ``aliases``.
79
80 ``name`` is optional, and should be a string if given. It's used to
81 tell ParserContext objects apart, and for use in a Parser when
82 determining what chunk of input might belong to a given ParserContext.
83
84 ``aliases`` is also optional and should be an iterable containing
85 strings. Parsing will honor any aliases when trying to "find" a given
86 context in its input.
87
88 May give one or more ``args``, which is a quick alternative to calling
89 ``for arg in args: self.add_arg(arg)`` after initialization.
90 """
91 self.args = Lexicon()
92 self.positional_args: List[Argument] = []
93 self.flags = Lexicon()
94 self.inverse_flags: Dict[str, str] = {} # No need for Lexicon here
95 self.name = name
96 self.aliases = aliases
97 for arg in args:
98 self.add_arg(arg)
99
100 def __repr__(self) -> str:
101 aliases = ""

Callers

nothing calls this directly

Calls 1

add_argMethod · 0.95

Tested by

no test coverage detected