本文整理汇总了Python中cmd.Cmd.get_names方法的典型用法代码示例。如果您正苦于以下问题:Python Cmd.get_names方法的具体用法?Python Cmd.get_names怎么用?Python Cmd.get_names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmd.Cmd
的用法示例。
在下文中一共展示了Cmd.get_names方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_help
# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import get_names [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
示例2: get_names
# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import get_names [as 别名]
def get_names(self):
ret = []
ret.extend(Cmd.get_names(self))
ret.extend(self.extcmds.keys())
return ret
示例3: get_names
# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import get_names [as 别名]
def get_names(self):
names = Cmd.get_names(self)
names = [ x for x in set(names) if x.startswith('do_') ]
names.sort()
return names
# Automatically autocomplete commands, even if Tab wasn't pressed.
# The prefix is removed from the line and stored in self.cmdprefix.
# Also implement the commands that consist of a symbol character.
示例4: do_help
# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import get_names [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))
示例5: do_help
# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import get_names [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)
示例6: get_names
# 需要导入模块: from cmd import Cmd [as 别名]
# 或者: from cmd.Cmd import get_names [as 别名]
def get_names(self):
secret = "do_" + Console.secret
names = Cmd.get_names(self)
if secret in names:
names.remove(secret)
return names
# Dunno about you reversing it but I had fun coding this :D