当前位置: 首页>>代码示例>>Python>>正文


Python Cmd.do_help方法代码示例

本文整理汇总了Python中cmd.Cmd.do_help方法的典型用法代码示例。如果您正苦于以下问题:Python Cmd.do_help方法的具体用法?Python Cmd.do_help怎么用?Python Cmd.do_help使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmd.Cmd的用法示例。


在下文中一共展示了Cmd.do_help方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_help

# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import do_help [as 别名]
def get_help(self, commands):
        msg = set()
        for name in commands:
            if name != 'do_help':
                try:
                    doc = getattr(self, name).__doc__.split('\n')
                except Exception:
                    return ( "No help available when Python"
                             " is run with the -OO switch." )
                for x in doc:
                    x = x.strip()
                    if x:
                        msg.add('  %s' % x)
        msg = list(msg)
        msg.sort()
        msg = '\n'.join(msg)
        return msg

    # Parse the prefix and remove it from the command line. 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:21,代码来源:interactive.py

示例2: do_help

# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import do_help [as 别名]
def do_help(self, line):
        """
    \x1b[32m\x1b[1mhelp\x1b[0m
    \x1b[32m\x1b[1mhelp\x1b[0m \x1b[34m\x1b[1m*\x1b[0m
    \x1b[32m\x1b[1mhelp\x1b[0m <\x1b[34m\x1b[1mcommand\x1b[0m> [\x1b[34m\x1b[1mcommand\x1b[0m...]

    Without arguments, shows the list of available commands.
    With arguments, shows the help for one or more commands.
    Use "\x1b[34m\x1b[1mhelp *\x1b[0m" to show help for all commands at once.
    The question mark "\x1b[34m\x1b[1m?\x1b[0m" can be used as an alias for "\x1b[34m\x1b[1mhelp\x1b[0m".\n"""
        if not line.strip():
            Cmd.do_help(self, line)
        else:
            commands = split(line, comments=True)
            if commands == ["*"]:
                commands = self.get_names()
                commands = [ x[3:] for x in commands if x.startswith("do_") ]
                commands.sort()
            last = len(commands) - 1
            index = 0
            for cmd in commands:
                Cmd.do_help(self, cmd)
                if index < last:
                    print Fore.RED + Style.BRIGHT + ("-" * 79) + Style.RESET_ALL
                index += 1 
开发者ID:nccgroup,项目名称:thetick,代码行数:27,代码来源:tick.py

示例3: do_help

# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import do_help [as 别名]
def do_help(self, arg):
        if arg:
            Cmd.do_help(self, arg)
        else:
            print_say("", self)
            headerString = "These are valid commands for Jarvis"
            formatString = "Format: command ([aliases for command])"
            print_say(headerString, self)
            print_say(formatString, self, Fore.BLUE)
            pluginDict = self._plugin_manager.get_plugins()
            uniquePlugins = {}
            for key in pluginDict.keys():
                plugin = pluginDict[key]
                if(plugin not in uniquePlugins.keys()):
                    uniquePlugins[plugin.get_name()] = plugin
            helpOutput = []
            for name in sorted(uniquePlugins.keys()):
                if (name == "help"):
                    continue
                try:
                    aliasString = ", ".join(uniquePlugins[name].alias())
                    if (aliasString != ""):
                        pluginOutput = "* " + name + " (" + aliasString + ")"
                        helpOutput.append(pluginOutput)
                    else:
                        helpOutput.append("* " + name)
                except AttributeError:
                    helpOutput.append("* " + name)

            Cmd.columnize(self, helpOutput) 
开发者ID:sukeesh,项目名称:Jarvis,代码行数:32,代码来源:CmdInterpreter.py

示例4: do_help

# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import do_help [as 别名]
def do_help(self, arg):
        """
        ? - show the list of available commands
        ? * - show help for all commands
        ? <command> [command...] - show help for the given command(s)
        help - show the list of available commands
        help * - show help for all commands
        help <command> [command...] - show help for the given command(s)
        """
        if not arg:
            Cmd.do_help(self, arg)
        elif arg in ('?', 'help'):
            # An easter egg :)
            print("  Help! I need somebody...")
            print("  Help! Not just anybody...")
            print("  Help! You know, I need someone...")
            print("  Heeelp!")
        else:
            if arg == '*':
                commands = self.get_names()
                commands = [ x for x in commands if x.startswith('do_') ]
            else:
                commands = set()
                for x in arg.split(' '):
                    x = x.strip()
                    if x:
                        for n in self.completenames(x):
                            commands.add( 'do_%s' % n )
                commands = list(commands)
                commands.sort()
            print(self.get_help(commands)) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:33,代码来源:interactive.py

示例5: do_help

# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import do_help [as 别名]
def do_help(self, arg):
        """
        ? - show the list of available commands
        ? * - show help for all commands
        ? <command> [command...] - show help for the given command(s)
        help - show the list of available commands
        help * - show help for all commands
        help <command> [command...] - show help for the given command(s)
        """
        if not arg:
            Cmd.do_help(self, arg)
        elif arg in ('?', 'help'):
            # An easter egg :)
            print "  Help! I need somebody..."
            print "  Help! Not just anybody..."
            print "  Help! You know, I need someone..."
            print "  Heeelp!"
        else:
            if arg == '*':
                commands = self.get_names()
                commands = [ x for x in commands if x.startswith('do_') ]
            else:
                commands = set()
                for x in arg.split(' '):
                    x = x.strip()
                    if x:
                        for n in self.completenames(x):
                            commands.add( 'do_%s' % n )
                commands = list(commands)
                commands.sort()
            print self.get_help(commands) 
开发者ID:debasishm89,项目名称:OpenXMolar,代码行数:33,代码来源:interactive.py


注:本文中的cmd.Cmd.do_help方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。