def _parse_args(argv):
    try:
        return parse_args(argv[1:])
    except ArgumentSyntaxError as e:
        sys.stderr.write(e.usage)
        sys.stderr.write(str(e))
        exit(1)
Esempio n. 2
0
def start(argv, context: Context):
    with context:
        # setup friendly interrupt message
        signal.signal(signal.SIGINT, interrupt_handler)

        load_config()

        args = parse_args(argv[1:])

        setattr(args, 'arg_string', ' '.join(argv[1:]))
        set_log_level(args)

        args.func(args)

        return 0
def _run_command(command: Command, state: _ScriptExecutionState):
    cmd = command.command.render(state.values)
    try:
        sub_args = arg_parser.parse_args(shlex.split(cmd))
    except ArgumentSyntaxError as e:
        raise McmdError(message=str(e))

    _block_nested_scripts(sub_args.command)

    if state.options.dry_run:
        log.info(cmd)
    else:
        setattr(sub_args, 'arg_string', cmd)

        sub_args.func(sub_args, nested=True)
def _run_command(line: str):
    sub_args = arg_parser.parse_args(shlex.split(line))
    setattr(sub_args, 'arg_string', line)
    _fail_on_run_command(sub_args)
    sub_args.func(sub_args, nested=True)