def parse_args(argv=sys.argv[1:], prog=sys.argv[0], *, subset=None): import argparse parser = argparse.ArgumentParser(prog=prog or get_prog(), ) processors = add_commands_cli( parser, commands={k: v[1] for k, v in COMMANDS.items()}, commonspecs=[ add_verbosity_cli, add_traceback_cli, ], subset=subset, ) args = parser.parse_args(argv) ns = vars(args) cmd = ns.pop('cmd') verbosity, traceback_cm = process_args_by_key( args, processors[cmd], ['verbosity', 'traceback_cm'], ) # "verbosity" is sent to the commands, so we put it back. args.verbosity = verbosity return cmd, ns, verbosity, traceback_cm
def parse_args(argv=sys.argv[1:], prog=sys.argv[0], *, subset='preprocess', excluded=None, **prepr_kwargs): import argparse parser = argparse.ArgumentParser(prog=prog or get_prog(), ) processors = add_commands_cli( parser, commands={k: v[1] for k, v in COMMANDS.items()}, commonspecs=[ add_verbosity_cli, add_traceback_cli, ], subset=subset, ) args = parser.parse_args(argv) ns = vars(args) cmd = ns.pop('cmd') verbosity, traceback_cm = process_args_by_key( args, processors[cmd], ['verbosity', 'traceback_cm'], ) return cmd, ns, verbosity, traceback_cm
def parse_args(argv=sys.argv[1:], prog=None, *, subset=None): import argparse parser = argparse.ArgumentParser(prog=prog or get_prog(), ) # if subset == 'check' or subset == ['check']: # if checks is not None: # commands = dict(COMMANDS) # commands['check'] = list(commands['check']) # cli = commands['check'][1][0] # commands['check'][1][0] = (lambda p: cli(p, checks=checks)) processors = add_commands_cli( parser, commands=COMMANDS, commonspecs=[ add_verbosity_cli, add_traceback_cli, ], subset=subset, ) args = parser.parse_args(argv) ns = vars(args) cmd = ns.pop('cmd') verbosity, traceback_cm = process_args_by_key( args, processors[cmd], ['verbosity', 'traceback_cm'], ) if cmd != 'parse': # "verbosity" is sent to the commands, so we put it back. args.verbosity = verbosity return cmd, ns, verbosity, traceback_cm