Prints parser's help.

        :param prog_name: vcs main script name
        :param subcommand: command name
483427
def print_help(self, prog_name, subcommand):
        
        parser = self.get_parser(prog_name, subcommand)
        parser.print_help()
958888
def print_subprocess_output(subp):
    ''''''
    if subp:
        if subp.errorcode != 0:
            print('<error errorcode="%s">' % str(subp.errorcode))
            print(subp.stderr)
            print("</error>")
            print_tag('stdout', '\n%s\n' % subp.stdout)
        else:
            print_tag('success', '\n%s\n' % subp.stdout)
            print_tag('warnings', '\n%s\n' % subp.stderr)
289266
def add_subcommands(parser, commands):
    ""
    subps = parser.add_subparsers()
    for cmd, cls in commands:
        subp = subps.add_parser(cmd, help=cls.__doc__)
        add_args = getattr(cls, 'add_arguments', None)
        if add_args:
            add_args(subp)
        handler = getattr(cls, 'handle', None)
        if handler:
            subp.set_defaults(handler=handler)
1263550
def run_command(self, args):
        
        parsed_args = self.parser.parse_args(args)
        if hasattr(parsed_args, 'func'):
            parsed_args.func(parsed_args)
        else:
            self.parser.print_help()
706189
def get_application_parser(commands):
    

    parser = argparse.ArgumentParser(
        description=configuration.APPLICATION_DESCRIPTION,
        usage =configuration.EXECUTABLE_NAME + ' [sub-command] [options]',
        add_help=False)

    parser.add_argument(
        'sub_command',
        choices=[name for name in commands],
        nargs="?")

    parser.add_argument("-h", "--help", action="store_true")
    return parser
980393
def parse_command_line(self, argv=None):
        
        argv = sys.argv[1:] if argv is None else argv
        self.argv = [py3compat.cast_unicode(arg) for arg in argv]

        # Append Provider Class to the list of configurable items.
        ProviderClass = getattr(providers, self.provider_type)
        self.classes.append(ProviderClass)

        if any(x in self.argv for x in ('-h', '--help-all', '--help')):
            self.print_help('--help-all' in self.argv)
            self.exit(0)

        if '--version' in self.argv or '-V' in self.argv:
            self.print_version()
            self.exit(0)

        # Generate a configuration file if flag is given.
        if '--generate-config' in self.argv:
            conf = self.generate_config_file()
            with open(self.config_file, 'w') as f:
                f.write(conf)
            self.exit(0)

        # If not config, parse commands.
        ## Run sanity checks.
        # Check that the minimum number of arguments have been called.
        if len(self.argv) < 2:
            raise JhubctlError(
                "Not enough arguments. \n\n"
                "Expected: jhubctl <action> <resource> <name>")

        # Check action
        self.resource_action = self.argv[0]
        if self.resource_action not in self.subcommands:
            raise JhubctlError(
                f"Subcommand is not recognized; must be one of these: {self.subcommands}")

        # Check resource
        self.resource_type = self.argv[1]
        if self.resource_type not in self.resources:
            raise JhubctlError(
                f"First argument after a subcommand must one of these"
                f"resources: {self.resources}"
            )

        # Get name of resource.
        try:
            self.resource_name = self.argv[2]
        except IndexError:
            if self.resource_action != "get":
                raise JhubctlError(
                    "Not enough arguments. \n\n"
                    "Expected: jhubctl <action> <resource> <name>")
            else:
                self.resource_name = None

        # flatten flags&aliases, so cl-args get appropriate priority:
        flags, aliases = self.flatten_flags()
        loader = KVArgParseConfigLoader(argv=argv, aliases=aliases,
                                        flags=flags, log=self.log)
        config = loader.load_config()
        self.update_config(config)
        # store unparsed args in extra_args
        self.extra_args = loader.extra_args
641169
def parser(subparsers):
    ""

    # create the parser for the version subcommand.
    parser_version = subparsers.add_parser(
        'version',
        help="Output the version of %(prog)s to the console.")
    parser_version.set_defaults(func=command_version)

    return parser_version
401104
def print_help(self, session, command=None):
        
        if command:
            # Single command mode
            if command in self._commands:
                # Argument is a name space
                self.__print_namespace_help(session, command)
                was_namespace = True
            else:
                was_namespace = False

            # Also print the name of matching commands
            try:
                # Extract command name space and name
                possibilities = self.get_ns_commands(command)
            except ValueError as ex:
                # Unknown command
                if not was_namespace:
                    # ... and no name space were matching either -> error
                    session.write_line(str(ex))
                    return False
            else:
                # Print the help of the found command
                if was_namespace:
                    # Give some space
                    session.write_line("\n\n")

                for namespace, cmd_name in possibilities:
                    self.__print_namespace_help(session, namespace, cmd_name)
        else:
            # Get all name spaces
            namespaces = list(self._commands.keys())
            namespaces.remove(DEFAULT_NAMESPACE)
            namespaces.sort()
            namespaces.insert(0, DEFAULT_NAMESPACE)

            first_ns = True
            for namespace in namespaces:
                if not first_ns:
                    # Add empty lines
                    session.write_line("\n\n")

                # Print the help of all commands
                self.__print_namespace_help(session, namespace)
                first_ns = False

        return None
1239618
def _do_print(self, cmd, args):
        
        name = args[0].strip()
        if not name:
            self.stderr.write('TODO: Display names of inspectable objects.\n')
            return
        try:
            code = textwrap.dedent(r'''
                    self.stdout.write(name + ':\n' + textwrap.indent(pprint.pformat({}), '    ') + '\n')
                    ''').format(name).strip()
            eval(code, globals(), locals())
        except NameError:
            self.stderr.write("p: name '{}' is not defined\n".format(name))
        self.stdout.flush()
58445
def show_help(command_name: str = None, raw_args: str = '') -> Response:
    

    response = Response()

    cmds = fetch()
    if command_name and command_name in cmds:
        parser, result = parse.get_parser(
            cmds[command_name],
            parse.explode_line(raw_args),
            dict()
        )

        if parser is not None:
            out = parser.format_help()
            return response.notify(
                kind='INFO',
                code='COMMAND_DESCRIPTION'
            ).kernel(
                commands=out
            ).console(
                out,
                whitespace=1
            ).response

    environ.log_header('Available Commands')
    response.consume(print_module_help())

    return response.fail(
        code='NO_SUCH_COMMAND',
        message='Failed to show command help for "{}"'.format(command_name)
    ).console(
        """
        For more information on the various commands, enter help on the
        specific command:

            help [COMMAND]
        """,
        whitespace_bottom=1
    ).response
1281361
def parse_host_args(self, *args):
        
        self.subcommand = None
        new_args = args
        try:
            sub = args[0]
            if sub in ['project','templates','static','media','wsgi','webconf']:
                self.subcommand = args[0]
                new_args = args[1:]
        except IndexError:
            pass
        
        return ','.join(new_args)
1020090
def execute
      subcmd_name = @match[1]
      return puts(help) unless subcmd_name

      subcmd = subcommand_list.match(subcmd_name)
      raise CommandNotFound.new(subcmd_name, self.class) unless subcmd

      subcmd.new(processor, arguments).execute
    end
1200549
def do_help(self, args: argparse.Namespace) -> None:
        """"""
        if not args.command or args.verbose:
            self._help_menu(args.verbose)

        else:
            # Getting help for a specific command
            func = self.cmd_func(args.command)
            help_func = getattr(self, HELP_FUNC_PREFIX + args.command, None)

            # If the command function uses argparse, then use argparse's help
            if func and hasattr(func, 'argparser'):
                completer = AutoCompleter(getattr(func, 'argparser'), self)
                tokens = [args.command] + args.subcommand
                self.poutput(completer.format_help(tokens))

            # If there is no help information then print an error
            elif help_func is None and (func is None or not func.__doc__):
                err_msg = self.help_error.format(args.command)
                self.decolorized_write(sys.stderr, "{}\n".format(err_msg))

            # Otherwise delegate to cmd base class do_help()
            else:
                super().do_help(args.command)
399539
def help(subcommand=None):
    

    if not subcommand:
        print("blurb version", __version__)
        print()
        print("Management tool for CPython Misc/NEWS and Misc/NEWS.d entries.")
        print()
        print("Usage:")
        print("    blurb [subcommand] [options...]")
        print()

        # print list of subcommands
        summaries = []
        longest_name_len = -1
        for name, fn in subcommands.items():
            if name.startswith('-'):
                continue
            longest_name_len = max(longest_name_len, len(name))
            if not fn.__doc__:
                error("help is broken, no docstring for " + fn.__name__)
            fields = fn.__doc__.lstrip().split("\n")
            if not fields:
                first_line = "(no help available)"
            else:
                first_line = fields[0]
            summaries.append((name, first_line))
        summaries.sort()

        print("Available subcommands:")
        print()
        for name, summary in summaries:
            print(" ", name.ljust(longest_name_len), " ", summary)

        print()
        print("If blurb is run without any arguments, this is equivalent to 'blurb add'.")

        sys.exit(0)

    fn = get_subcommand(subcommand)
    doc = fn.__doc__.strip()
    if not doc:
        error("help is broken, no docstring for " + subcommand)

    options = []
    positionals = []

    nesting = 0
    for name, p in inspect.signature(fn).parameters.items():
        if p.kind == inspect.Parameter.KEYWORD_ONLY:
            short_option = name[0]
            options.append(f(" [-{short_option}|--{name}]"))
        elif p.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD:
            positionals.append(" ")
            has_default = (p.default != inspect._empty)
            if has_default:
                positionals.append("[")
                nesting += 1
            positionals.append(f("<{name}>"))
    positionals.append("]" * nesting)


    parameters = "".join(options + positionals)
    print(f("blurb {subcommand}{parameters}"))
    print()
    print(doc)
    sys.exit(0)
182360
def handle_argv(self, prog_name, argv):
        
        options, args = self.parse_options(prog_name, argv)
        return self.run(*args, **vars(options))
816241
def get_parser(self, prog_name, subcommand):
        
        parser = OptionParser(
            prog=prog_name,
            usage=self.usage(subcommand),
            version=self.get_version(),
            option_list=sorted(self.get_option_list()))
        return parser
234670
def create_parser(self, prog_name, subcommand):
        
        parser = OptionParser(prog=prog_name,
                              usage=self.usage(subcommand),
                              option_list=self.option_list)
        return parser