MCPcopy Index your code
hub / github.com/python/cpython / _add_cmd_cli

Function _add_cmd_cli

Tools/c-analyzer/c_common/scriptutil.py:453–475  ·  view source on GitHub ↗
(parser, commonspecs, argspecs)

Source from the content-addressed store, hash-verified

451
452
453def _add_cmd_cli(parser, commonspecs, argspecs):
454 processors = []
455 argspecs = list(commonspecs or ()) + list(argspecs or ())
456 for argspec in argspecs:
457 if callable(argspec):
458 procs = argspec(parser)
459 _add_procs(processors, procs)
460 else:
461 if not argspec:
462 raise NotImplementedError
463 args = list(argspec)
464 if not isinstance(args[-1], str):
465 kwargs = args.pop()
466 if not isinstance(args[0], str):
467 try:
468 args, = args
469 except (TypeError, ValueError):
470 parser.error(f'invalid cmd args {argspec!r}')
471 else:
472 kwargs = {}
473 parser.add_argument(*args, **kwargs)
474 # There will be nothing to process.
475 return processors
476
477
478def _flatten_processors(processors):

Callers 1

add_commands_cliFunction · 0.85

Calls 5

listClass · 0.85
_add_procsFunction · 0.85
popMethod · 0.45
errorMethod · 0.45
add_argumentMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…