Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
def register_options_special(global_context):
    # Register options for special topics not attached to a "real" command
    # (e.g. 'commands')
    context = OptionsContext()

    def print_usage():
        print(get_usage(global_context))

    context.parser.print_help = print_usage
    global_context.register_options_context_without_command(
        "commands", context)

    context = OptionsContext()

    def print_help():
        global_options = global_context.retrieve_options_context("")
        p = global_options.parser
        return (p.print_help())

    context.parser.print_help = print_help
    global_context.register_options_context_without_command("globals", context)
Ejemplo n.º 3
0
    def setUp(self):
        self.run_node = create_first_node(os.getcwd())

        registry = bento.commands.registries.CommandRegistry()

        # help command assumes those always exist
        registry.register("configure", Command)
        registry.register("build", Command)
        registry.register("install", Command)
        registry.register("sdist", Command)
        registry.register("build_wininst", Command)
        registry.register("build_egg", Command)
        self.registry = registry

        self.options_registry = bento.commands.registries.OptionsRegistry()
        self.options_registry.register("configure", OptionsContext())
Ejemplo n.º 4
0
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