MCPcopy
hub / github.com/tox-dev/tox / add_command

Method add_command

src/tox/config/cli/parser.py:180–211  ·  view source on GitHub ↗
(
        self,
        cmd: str,
        aliases: Sequence[str],
        help_msg: str,
        handler: Callable[[State], int],
        *,
        inherit: frozenset[str] = _INHERIT_ALL,
    )

Source from the content-addressed store, hash-verified

178 self._cmd = None
179
180 def add_command(
181 self,
182 cmd: str,
183 aliases: Sequence[str],
184 help_msg: str,
185 handler: Callable[[State], int],
186 *,
187 inherit: frozenset[str] = _INHERIT_ALL,
188 ) -> ArgumentParser:
189 if self._cmd is None:
190 msg = "no sub-command group allowed"
191 raise RuntimeError(msg)
192 sub_parser: ToxParser = self._cmd.add_parser(
193 cmd,
194 help=help_msg,
195 aliases=aliases,
196 formatter_class=HelpFormatter,
197 file_config=self.file_config,
198 )
199 sub_parser.of_cmd = cmd
200 sub_parser.inherit = inherit
201 content = sub_parser, handler
202 self.handlers[cmd] = content
203 for alias in aliases:
204 self.handlers[alias] = content
205 defaults: dict[str, Any] = {}
206 self._copy_arguments(sub_parser, defaults)
207 self._copy_groups(sub_parser, defaults)
208 self._add_env_arguments(sub_parser, defaults)
209 if defaults:
210 sub_parser.set_defaults(**defaults)
211 return sub_parser
212
213 def _copy_arguments(self, sub_parser: ToxParser, defaults: dict[str, Any]) -> None:
214 for args, of_type, kwargs in self._arguments:

Callers 12

tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
tox_add_optionFunction · 0.80
test_sub_sub_commandFunction · 0.80

Calls 3

_copy_argumentsMethod · 0.95
_copy_groupsMethod · 0.95
_add_env_argumentsMethod · 0.95

Tested by 1

test_sub_sub_commandFunction · 0.64