trepan/processor/command/base_submgr.py
def help(self, args):
        """Give help for a command which has subcommands. This can be
        called in several ways:
            help cmd
            help cmd subcmd
            help cmd commands

        Our shtick is to give help for the overall command only if
        subcommand or 'commands' is not given. If a subcommand is given and
        found, then specific help for that is given. If 'commands' is given
        we will list the all the subcommands.
        """
        if len(args) <= 2:
            # "help cmd". Give the general help for the command part.
            doc = self.__doc__ or self.run.__doc__
            if doc:
                self.rst_msg(doc.rstrip('\n'))
            else:
                self.proc.intf[-1].errmsg('Sorry - author mess up. ' +
                                          'No help registered for command' +
                                          self.name)
                pass
            return

        subcmd_name = args[2]

        if '*' == subcmd_name:
            self.section("List of subcommands for command '%s':" % self.name)
            self.msg(self.columnize_commands(self.cmds.list()))
            return

        # "help cmd subcmd". Give help specific for that subcommand.
        cmd = self.cmds.lookup(subcmd_name)
        if cmd:
            doc = cmd.__doc__ or cmd.run.__doc__
            if doc:
                self.proc.rst_msg(doc.rstrip('\n'))
            else:
                self.proc.intf[-1] \
                  .errmsg('Sorry - author mess up. No help registered for '
                          'subcommand %s of command %s' %
                          (subcmd_name, self.name))
                pass
        else:
            cmds = [c for c in self.cmds.list()
                    if re.match('^' + subcmd_name, c) ]
            if cmds == []:
                self.errmsg("No %s subcommands found matching /^%s/. "
                            "Try \"help\"." % (self.name, subcmd_name))
            else:
                self.section("Subcommand(s) of \"%s\" matching /^%s/:" %
                         (self.name, subcmd_name,))
                self.msg_nocr(self.columnize_commands(cmds))
                pass
            pass
        return
def help(self, args):
        """Give help for a command which has subcommands. This can be
        called in several ways:
            help cmd
            help cmd subcmd
            help cmd commands

        Our shtick is to give help for the overall command only if
        subcommand or 'commands' is not given. If a subcommand is given and
        found, then specific help for that is given. If 'commands' is given
        we will list the all the subcommands.
        """
        if len(args) <= 2:
            # "help cmd". Give the general help for the command part.
            doc = self.__doc__ or self.run.__doc__
            if doc:
                self.rst_msg(doc.rstrip('\n'))
            else:
                self.proc.intf[-1].errmsg('Sorry - author mess up. ' +
                                          'No help registered for command' +
                                          self.name)
                pass
            return

        subcmd_name = args[2]

        if '*' == subcmd_name:
            self.section("List of subcommands for command '%s':" % self.name)
            self.msg(self.columnize_commands(self.cmds.list()))
            return

        # "help cmd subcmd". Give help specific for that subcommand.
        cmd = self.cmds.lookup(subcmd_name)
        if cmd:
            doc = cmd.__doc__ or cmd.run.__doc__
            if doc:
                self.proc.rst_msg(doc.rstrip('\n'))
            else:
                self.proc.intf[-1] \
                  .errmsg('Sorry - author mess up. No help registered for '
                          'subcommand %s of command %s' %
                          (subcmd_name, self.name))
                pass
        else:
            cmds = [c for c in self.cmds.list()
                    if re.match('^' + subcmd_name, c) ]
            if cmds == []:
                self.errmsg("No %s subcommands found matching /^%s/. "
                            "Try \"help\"." % (self.name, subcmd_name))
            else:
                self.section("Subcommand(s) of \"%s\" matching /^%s/:" %
                         (self.name, subcmd_name,))
                self.msg_nocr(self.columnize_commands(cmds))
                pass
            pass
        return
Give help for a command which has subcommands. This can be
        called in several ways:
            help cmd
            help cmd subcmd
            help cmd commands

        Our shtick is to give help for the overall command only if
        subcommand or 'commands' is not given. If a subcommand is given and
        found, then specific help for that is given. If 'commands' is given
        we will list the all the subcommands.