generates the help text based on commands typed
510561
def generate_help_text(self):
        
        param_descrip = example = ""
        self.description_docs = u''

        rows, _ = get_window_dim()
        rows = int(rows)

        param_args = self.completer.leftover_args
        last_word = self.completer.unfinished_word
        command = self.completer.current_command
        new_command = ' '.join([command, last_word]).strip()

        if not self.completer.complete_command and new_command in self.completer.command_description:
            command = new_command

        # get command/group help
        if self.completer and command in self.completer.command_description:
            self.description_docs = u'{}'.format(self.completer.command_description[command])

        # get parameter help if full command
        if self.completer and command in self.completer.command_param_info:
            param = param_args[-1] if param_args else ''
            param = last_word if last_word.startswith('-') else param

            if param in self.completer.command_param_info[command] and self.completer.has_description(
                    command + " " + param):
                param_descrip = ''.join([
                    param, ":", '\n', self.completer.param_description.get(command + " " + param, '')])

            if command in self.completer.command_examples:
                string_example = []
                for example in self.completer.command_examples[command]:
                    for part in example:
                        string_example.append(part)
                ''.join(string_example)
                example = self._space_examples(
                    self.completer.command_examples[command], rows, self.example_page)

        return param_descrip, example
166173
def generate_command(name, tty_options)
      cmd = []
      cmd << name
      cmd += tty_options
      cmd << "`#{find_filters.join(' | ')}`"
      cmd.join(' ')
    end
449478
def do_help(self, arg):
        """"""

        if arg:
            # XXX check arg syntax
            try:
                func = getattr(self, 'help_' + arg)
            except AttributeError:
                try:
                    doc = getattr(self, 'do_' + arg).__doc__
                    if doc:
                        self.stdout.write("%s\n" % str(doc))
                        return
                except AttributeError:
                    pass
                self.stdout.write("%s\n" % str(self.nohelp % (arg,)))
                return
            func()
        else:
            names = self.get_names()
            cmds_doc = []
            cmds_undoc = []
            help_page = {}
            for name in names:
                if name[:5] == 'help_':
                    help_page[name[5:]] = 1
            names.sort()
            # There can be duplicates if routines overridden
            prevname = ''
            for name in names:
                if name[:3] == 'do_':
                    if name == prevname:
                        continue
                    prevname = name
                    cmd = name[3:]
                    if cmd in help_page:
                        cmds_doc.append(cmd)
                        del help_page[cmd]
                    elif getattr(self, name).__doc__:
                        cmds_doc.append(cmd)
                    else:
                        cmds_undoc.append(cmd)

            self.stdout.write("%s\n" % str(self.doc_leader))
            self.print_topics(self.doc_header, cmds_doc, 15, 80)
            self.print_topics(self.misc_header, list(help_page.keys()), 15, 80)
            self.print_topics(self.undoc_header, cmds_undoc, 15, 80)

            for topic in self.command_topics:
                topic_cmds = self.command_topics[topic]
                self.print_topics(string.capwords(topic + " commands"), topic_cmds, 15, 80)
947024
protected function showGeneralHelp()
    {
        $this->output->writeln("<yellow>Available commands:</yellow>");

        $longestName = 0;
        foreach ($this->app->getCommands() as $command) {
            $strlen = strlen($command->getName());
            if ($strlen > $longestName) {
                $longestName = $strlen;
            }
        }

        foreach ($this->app->getCommands() as $command) {
            $name = $command->getName();
            $this->output->write(str_pad("  <green>{$name}</green>", $longestName + 22, ' ', STR_PAD_RIGHT));
            $this->output->write("{$command->getDescription()}");
            $this->output->newline();
        }
    }
1152456
def format(self):
        

        values = {}
        title = "Description"
        description = self.command.description + "\n\n" + self.get_ending_note() if not self.is_cog() else inspect.getdoc(self.command)
        sections = []

        if isinstance(self.command, Command):
                description = self.command.short_doc
                sections = [{"name": "Usage", "value": self.get_command_signature()},
                            {"name": "More Info", "value": self.command.help.replace(self.command.short_doc, "").format(prefix=self.clean_prefix),
                             "inline": False}]

        def category(tup):
            cog = tup[1].cog_name
            return cog + ':' if cog is not None else '\u200bNo Category:'

        if self.is_bot():
            title = self.bot.user.display_name + " Help"
            data = sorted(self.filter_command_list(), key=category)
            for category, commands in itertools.groupby(data, key=category):
                section = {}
                commands = list(commands)
                if len(commands) > 0:
                    section['name'] = category
                section['value'] = self.add_commands(commands)
                section['inline'] = False
                sections.append(section)
        elif not sections or self.has_subcommands():
            section = {"name": "Commands:", "inline": False, "value": self.add_commands(self.filter_command_list())}
            sections.append(section)

        values['title'] = title
        values['description'] = description
        values['sections'] = sections
        return values
994642
def show_help(self):
        
        output = [
            'Usage %s subcommand [options] [args]' % self.prog_name,
            '',
            'Available commands:',
            '',
        ]
        for cmd in self.get_commands():
            output.append('  %s' % cmd)
        output += ['', '']
        self.stdout.write(u'\n'.join(output))
230804
def applyCommand(self):
        
        # generate the command information
        cursor      = self.textCursor()
        cursor.movePosition(cursor.EndOfLine)
        
        line        = projex.text.nativestring(cursor.block().text())
        at_end      = cursor.atEnd()
        modifiers   = QApplication.instance().keyboardModifiers()
        mod_mode    = at_end or modifiers == Qt.ShiftModifier
        
        # test the line for information
        if mod_mode and line.endswith(':'):
            cursor.movePosition(cursor.EndOfLine)
            
            line = re.sub('^>>> ', '', line)
            line = re.sub('^\.\.\. ', '', line)
            count = len(line) - len(line.lstrip()) + 4
            
            self.insertPlainText('\n... ' + count * ' ')
            return False
        
        elif mod_mode and line.startswith('...') and \
            (line.strip() != '...' or not at_end):
            cursor.movePosition(cursor.EndOfLine)
            line = re.sub('^\.\.\. ', '', line)
            count = len(line) - len(line.lstrip())
            self.insertPlainText('\n... ' + count * ' ')
            return False
        
        # if we're not at the end of the console, then add it to the end
        elif line.startswith('>>>') or line.startswith('...'):
            # move to the top of the command structure
            line = projex.text.nativestring(cursor.block().text())
            while line.startswith('...'):
                cursor.movePosition(cursor.PreviousBlock)
                line = projex.text.nativestring(cursor.block().text())
            
            # calculate the command
            cursor.movePosition(cursor.EndOfLine)
            line = projex.text.nativestring(cursor.block().text())
            ended = False
            lines = []
            
            while True:
                # add the new block
                lines.append(line)
                
                if cursor.atEnd():
                    ended = True
                    break
                
                # move to the next line
                cursor.movePosition(cursor.NextBlock)
                cursor.movePosition(cursor.EndOfLine)
                
                line = projex.text.nativestring(cursor.block().text())
                
                # check for a new command or the end of the command
                if not line.startswith('...'):
                    break
            
            command = '\n'.join(lines)
            
            # if we did not end up at the end of the command block, then
            # copy it for modification
            if not (ended and command):
                self.waitForInput()
                self.insertPlainText(command.replace('>>> ', ''))
                cursor.movePosition(cursor.End)
                return False
        
        else:
            self.waitForInput()
            return False
        
        self.executeCommand(command)
        return True
264679
def main_help_text(self, commands_only=False):
        
        if commands_only:
            usage = sorted(get_commands().keys())
        else:
            usage = [
                "",
                "Type '%s help <subcommand>' for help on a specific subcommand." % self.prog_name,
                "",
                "Available subcommands:",
            ]
            commands_dict = collections.defaultdict(lambda: [])
            for name, app in six.iteritems(get_commands()):
                if app == 'pug.crawlnmine':
                    app = 'pug'
                else:
                    app = app.rpartition('.')[-1]
                commands_dict[app].append(name)
            style = color_style()
            for app in sorted(commands_dict.keys()):
                usage.append("")
                usage.append(style.NOTICE("[%s]" % app))
                for name in sorted(commands_dict[app]):
                    usage.append("    %s" % name)
            # Output an extra note if settings are not properly configured
            if self.settings_exception is not None:
                usage.append(style.NOTICE(
                    "Note that only Django core commands are listed "
                    "as settings are not properly configured (error: %s)."
                    % self.settings_exception))

        return '\n'.join(usage)
1256819
def format_help(self) -> str:
        """"""
        formatter = self._get_formatter()

        # usage
        formatter.add_usage(self.usage, self._actions,
                            self._mutually_exclusive_groups)

        # description
        formatter.add_text(self.description)

        # Begin cmd2 customization (separate required and optional arguments)

        # positionals, optionals and user-defined groups
        for action_group in self._action_groups:
            if action_group.title == 'optional arguments':
                # check if the arguments are required, group accordingly
                req_args = []
                opt_args = []
                for action in action_group._group_actions:
                    if action.required:
                        req_args.append(action)
                    else:
                        opt_args.append(action)

                # separately display required arguments
                formatter.start_section('required arguments')
                formatter.add_text(action_group.description)
                formatter.add_arguments(req_args)
                formatter.end_section()

                # now display truly optional arguments
                formatter.start_section(action_group.title)
                formatter.add_text(action_group.description)
                formatter.add_arguments(opt_args)
                formatter.end_section()
            else:
                formatter.start_section(action_group.title)
                formatter.add_text(action_group.description)
                formatter.add_arguments(action_group._group_actions)
                formatter.end_section()

        # End cmd2 customization

        # epilog
        formatter.add_text(self.epilog)

        # determine help from format above
        return formatter.format_help()
411804
def cmd_help(self, *args):
        
        if len(args) > 0:
            cmdname = args[0].lower()
            try:
                method = getattr(self, "cmd_" + cmdname)
                doc = method.__doc__
                if doc is None:
                    self.log("Sorry, no documentation found for '%s'" % (
                        cmdname))
                else:
                    self.log("%s: %s" % (cmdname, doc))
            except AttributeError:
                self.log("No such command '%s'; type help for general help." % (
                    cmdname))
        else:
            res = []
            for attrname in dir(self):
                if attrname.startswith('cmd_'):
                    method = getattr(self, attrname)
                    doc = method.__doc__
                    cmdname = attrname[4:]
                    if doc is None:
                        doc = "no documentation"
                    res.append("%s: %s" % (cmdname, doc))
            self.log('\n'.join(res))
199735
def help(self, msg):
        
        commands = {}
        for handler in self.irc.handlers:
            if isinstance(handler, CommandHandler):
                for command in handler.triggers:
                    method = getattr(handler, command)
                    if hasattr(method, '__doc__') and method.__doc__:
                        commands[command] = method.__doc__.strip()
                    else:
                        commands[command] = 'No help available for command: %s' % command

        if len(msg.args) == 2:
            if msg.args[1] not in commands:
                message = 'Unknown command: %s' % msg.args[1]
            else:
                message = commands[msg.args[1]]
        else:
            message = 'Available commands: %s' % ', '.join(commands.keys())

        if msg.event == EVT_PUBLIC:
            self.irc.msg(msg.dst, message)
        elif msg.event == EVT_PRIVATE:
            self.irc.msg(msg.src, message)
        elif msg.event == EVT_NOTICE:
            self.irc.notice(msg.src, message)
1374547
def do_help(self, line):
        
        # We provide a help function so that we can trim the leading spaces
        # from the docstrings. The builtin help function doesn't do that.
        if not line:
            cmd.Cmd.do_help(self, line)
            self.print(EXIT_STR)
            return
        parser = self.create_argparser(line)
        if parser:
            parser.print_help()
            return
        try:
            doc = getattr(self, 'do_' + line).__doc__
            if doc:
                self.print("%s" % trim(doc))
                return
        except AttributeError:
            pass
        self.print(str(self.nohelp % (line,)))
70452
def _format_subcommand(command):
    """"""
    yield '.. object:: {}'.format(command.name)

    # click 7.0 stopped setting short_help by default
    if CLICK_VERSION < (7, 0):
        short_help = command.short_help
    else:
        short_help = command.get_short_help_str()

    if short_help:
        yield ''
        for line in statemachine.string2lines(
                short_help, tab_width=4, convert_whitespace=True):
            yield _indent(line)
412183
def text(*)
      if options[:help]
        invoke :help, ['text']
      elsif options.empty?
        invoke :help
      else
        require_relative 'commands/text'
        RubyEdit::Commands::Text.new(options).execute
      end
    end
578561
def generate_help():
  """"""
  help_text = '\nAvailable recipes:\n\n'
  recipes = config.Config.get_registered_recipes()
  for contents, _, _ in sorted(recipes, key=lambda k: k[0]['name']):
    help_text += ' {0:<35s}{1:s}\n'.format(
        contents['name'], contents.get('short_description', 'No description'))
  return help_text
568709
public function help()
    {
        echo PHP_EOL;
        $output = new Output;
        $output->write('Available Commands', [
            'color'     => 'red',
            'bold'      => true,
            'underline' => true,
        ]);
        echo PHP_EOL;

        $maxlen = 0;
        foreach ($this->supportedArgs as $key => $description) {
            $len = strlen($key);
            if ($len > $maxlen) {
                $maxlen = $len;
            }

        }

        foreach ($this->supportedArgs as $key => $description) {
            $len = strlen($key);
            $output->write(' ')
                ->write($key, ['color' => 'yellow'])
                ->write(str_repeat(' ', $maxlen - $len))
                ->write(' - ')
                ->write($description);

            echo PHP_EOL;
        }

        echo PHP_EOL;

    }
236096
def complete_help_subcommand(self, text: str, line: str, begidx: int, endidx: int) -> List[str]:
        """"""

        # Get all tokens through the one being completed
        tokens, _ = self.tokens_for_completion(line, begidx, endidx)

        if not tokens:
            return []

        # Must have at least 3 args for 'help command sub-command'
        if len(tokens) < 3:
            return []

        # Find where the command is by skipping past any flags
        cmd_index = 1
        for cur_token in tokens[cmd_index:]:
            if not cur_token.startswith('-'):
                break
            cmd_index += 1

        if cmd_index >= len(tokens):
            return []

        command = tokens[cmd_index]
        matches = []

        # Check if this is a command with an argparse function
        func = self.cmd_func(command)
        if func and hasattr(func, 'argparser'):
            completer = AutoCompleter(getattr(func, 'argparser'), self)
            matches = completer.complete_command_help(tokens[cmd_index:], text, line, begidx, endidx)

        return matches