def UsageString(component, trace=None, verbose=False):
"""Returns a string showing how to use the component as a Fire command."""
command = trace.GetCommand() + ' ' if trace else ''
if inspect.isroutine(component) or inspect.isclass(component):
spec = inspectutils.GetFullArgSpec(component)
return _UsageStringFromFullArgSpec(command, spec)
if isinstance(component, (list, tuple)):
length = len(component)
if length == 0:
return command
if length == 1:
return command + '[0]'
return command + '[0..{cap}]'.format(cap=length - 1)
completions = completion.Completions(component, verbose)
if command:
completions = [''] + completions
return '\n'.join(command + end for end in completions)
评论列表
文章目录