cli.py 文件源码

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

项目:certbot 作者: nikoloskii 项目源码 文件源码
def __init__(self, args, plugins, detect_defaults=False):
        from certbot import main
        self.VERBS = {"auth": main.obtain_cert, "certonly": main.obtain_cert,
                      "config_changes": main.config_changes, "run": main.run,
                      "install": main.install, "plugins": main.plugins_cmd,
                      "register": main.register, "renew": main.renew,
                      "revoke": main.revoke, "rollback": main.rollback,
                      "everything": main.run}

        # List of topics for which additional help can be provided
        HELP_TOPICS = ["all", "security", "paths", "automation", "testing"] + list(self.VERBS)

        plugin_names = list(plugins)
        self.help_topics = HELP_TOPICS + plugin_names + [None]
        usage, short_usage = usage_strings(plugins)
        self.parser = configargparse.ArgParser(
            usage=short_usage,
            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
            args_for_setting_config_path=["-c", "--config"],
            default_config_files=flag_default("config_files"))

        # This is the only way to turn off overly verbose config flag documentation
        self.parser._add_config_file_help = False  # pylint: disable=protected-access

        self.detect_defaults = detect_defaults

        self.args = args
        self.determine_verb()
        help1 = self.prescan_for_flag("-h", self.help_topics)
        help2 = self.prescan_for_flag("--help", self.help_topics)
        assert max(True, "a") == "a", "Gravity changed direction"
        self.help_arg = max(help1, help2)
        if self.help_arg is True:
            # just --help with no topic; avoid argparse altogether
            print(usage)
            sys.exit(0)
        self.visible_topics = self.determine_help_topics(self.help_arg)
        self.groups = {}       # elements are added by .add_group()
        self.defaults = {}  # elements are added by .parse_args()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号