当前位置: 首页>>代码示例>>Python>>正文


Python OptionsContext.add_option方法代码示例

本文整理汇总了Python中bento.commands.options.OptionsContext.add_option方法的典型用法代码示例。如果您正苦于以下问题:Python OptionsContext.add_option方法的具体用法?Python OptionsContext.add_option怎么用?Python OptionsContext.add_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bento.commands.options.OptionsContext的用法示例。


在下文中一共展示了OptionsContext.add_option方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_simple

# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import add_option [as 别名]
    def test_simple(self):
        help = HelpCommand()
        options = OptionsContext()
        for option in HelpCommand.common_options:
            options.add_option(option)
        context = CmdContext([], options, None, None)

        help.run(context)
开发者ID:abadger,项目名称:Bento,代码行数:10,代码来源:test_core.py

示例2: test_command

# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import add_option [as 别名]
    def test_command(self):
        help = HelpCommand()
        options = OptionsContext()
        for option in HelpCommand.common_options:
            options.add_option(option)
        context = CmdContext(["configure"], options, None, None)
        context.options_registry = self.options_registry

        help.run(context)
开发者ID:abadger,项目名称:Bento,代码行数:11,代码来源:test_core.py

示例3: test_simple

# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import add_option [as 别名]
    def test_simple(self):
        help = HelpCommand()
        options = OptionsContext()
        for option in HelpCommand.common_options:
            options.add_option(option)
        global_context = GlobalContext(self.registry, None, None, None)
        context = HelpContext(global_context, [], options, None, None)

        help.run(context)
开发者ID:pberkes,项目名称:Bento,代码行数:11,代码来源:test_core.py

示例4: test_simple

# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import add_option [as 别名]
    def test_simple(self):
        help = HelpCommand()
        options = OptionsContext()
        for option in HelpCommand.common_options:
            options.add_option(option)
        global_context = GlobalContext(None,
                commands_registry=self.registry,
                options_registry=self.options_registry)
        pkg = PackageDescription()
        context = HelpContext(global_context, [], options, pkg, self.run_node)

        run_command_in_context(context, help)
开发者ID:Web5design,项目名称:Bento,代码行数:14,代码来源:test_core.py

示例5: parse_global_options

# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import add_option [as 别名]
def parse_global_options(argv):
    context = OptionsContext(usage="%prog [options] [cmd_name [cmd_options]]")
    context.add_option(Option("--version", "-v", dest="show_version", action="store_true",
                              help="Version"))
    context.add_option(Option("--full-version", dest="show_full_version", action="store_true",
                              help="Full version"))
    context.add_option(Option("--build-directory", dest="build_directory",
                              help="Build directory as relative path from cwd (default: '%default')"))
    context.add_option(Option("--bento-info", dest="bento_info",
                              help="Bento location as a relative path from cwd (default: '%default'). " \
                                   "The base name (without its component) must be 'bento.info("))
    context.add_option(Option("-h", "--help", dest="show_help", action="store_true",
                              help="Display help and exit"))
    context.parser.set_defaults(show_version=False, show_full_version=False, show_help=False,
                                build_directory="build", bento_info="bento.info")
    OPTIONS_REGISTRY.register("", context)

    global_args, cmd_args = [], []
    for i, a in enumerate(argv):
        if a.startswith("-"):
            global_args.append(a)
        else:
            cmd_args = argv[i:]
            break

    ret = {"cmd_name": None, "cmd_opts": None}
    if cmd_args:
        ret["cmd_name"] = cmd_args[0]
        ret["cmd_opts"] = cmd_args[1:]

    o, a = context.parser.parse_args(global_args)
    ret["show_usage"] = o.show_help
    ret["build_directory"] = o.build_directory
    if not os.path.basename(o.bento_info) == BENTO_SCRIPT:
        context.parser.error("Invalid value for --bento-info: %r (basename should be %r)" % \
                             (o.bento_info, BENTO_SCRIPT))

    ret["bento_info"] = o.bento_info
    ret["show_version"] = o.show_version
    ret["show_full_version"] = o.show_full_version

    return ret
开发者ID:pberkes,项目名称:Bento,代码行数:44,代码来源:bentomaker.py

示例6: create_global_options_context

# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import add_option [as 别名]
def create_global_options_context():
    context = OptionsContext(usage="%prog [options] [cmd_name [cmd_options]]")
    context.add_option(Option("--version", "-v", dest="show_version", action="store_true",
                              help="Version"))
    context.add_option(Option("--full-version", dest="show_full_version", action="store_true",
                              help="Full version"))
    context.add_option(Option("--build-directory", dest="build_directory",
                              help="Build directory as relative path from cwd (default: '%default')"))
    context.add_option(Option("--bento-info", dest="bento_info",
                              help="Bento location as a relative path from cwd (default: '%default'). " \
                                   "The base name (without its component) must be 'bento.info("))
    context.add_option(Option("--disable-autoconfigure", dest="disable_autoconfigure",
                              action="store_true",
                              default=False,
                              help="""\
Do not automatically run configure before build. In this mode, the user is
expected to know what he is doing. This is mainly useful for developers, to
avoid running configure everytime (default: '%default')."""))
    context.add_option(Option("-h", "--help", dest="show_help", action="store_true",
                              help="Display help and exit"))
    context.parser.set_defaults(show_version=False, show_full_version=False, show_help=False,
                                build_directory="build", bento_info="bento.info")
    return context
开发者ID:dholth,项目名称:Bento,代码行数:25,代码来源:bentomaker.py


注:本文中的bento.commands.options.OptionsContext.add_option方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。