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)
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)
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)
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)
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
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
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