dispatcher.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:rcli 作者: contains-io 项目源码 文件源码
def _run_command(argv):
    # type: (typing.List[str]) -> typing.Any
    """Run the command with the given CLI options and exit.

    Command functions are expected to have a __doc__ string that is parseable
    by docopt.

    Args:
        argv: The list of command line arguments supplied for a command. The
            first argument is expected to be the name of the command to be run.
            Note that this is different than the full arguments parsed by
            docopt for the entire program.

    Raises:
        ValueError: Raised if the user attempted to run an invalid command.
    """
    command_name, argv = _get_command_and_argv(argv)
    _LOGGER.info('Running command "%s %s" with args: %s', settings.command,
                 command_name, argv)
    subcommand = _get_subcommand(command_name)
    func = call.get_callable(subcommand)
    doc = usage.format_usage(subcommand.__doc__)
    args = _get_parsed_args(command_name, doc, argv)
    return call.call(func, args) or 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号