MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / cmd_wrapper

Function cmd_wrapper

cmd2/decorators.py:177–189  ·  view source on GitHub ↗

Command function wrapper which translates command line into an argument list and calls actual command function. :param args: All positional arguments to this function. We're expecting there to be: cmd2_app, statement: Union[Statement, str]

(*args: Any, **kwargs: Any)

Source from the content-addressed store, hash-verified

175
176 @functools.wraps(func)
177 def cmd_wrapper(*args: Any, **kwargs: Any) -> bool | None:
178 """Command function wrapper which translates command line into an argument list and calls actual command function.
179
180 :param args: All positional arguments to this function. We're expecting there to be:
181 cmd2_app, statement: Union[Statement, str]
182 contiguously somewhere in the list
183 :param kwargs: any keyword arguments being passed to command function
184 :return: return value of command function
185 """
186 cmd2_app, statement = _parse_positionals(args)
187 _, command_arg_list = cmd2_app.statement_parser.get_command_arg_list(command_name, statement, preserve_quotes)
188 func_arg_list = _arg_swap(args, statement, command_arg_list)
189 return func(*func_arg_list, **kwargs)
190
191 command_name = func.__name__[len(constants.COMMAND_FUNC_PREFIX) :]
192 cmd_wrapper.__doc__ = func.__doc__

Callers

nothing calls this directly

Calls 6

_parse_positionalsFunction · 0.85
_arg_swapFunction · 0.85
get_command_arg_listMethod · 0.80
_resolve_func_selfMethod · 0.80
output_toMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…