43
43
outfile.write(topics[0].get_help_text())
45
help_on_command(topic, outfile=outfile)
48
def command_usage(cmd_object):
49
"""Return single-line grammar for command.
51
Only describes arguments, not options.
53
s = 'bzr ' + cmd_object.name() + ' '
54
for aname in cmd_object.takes_args:
56
if aname[-1] in ['$', '+']:
57
aname = aname[:-1] + '...'
58
elif aname[-1] == '?':
59
aname = '[' + aname[:-1] + ']'
60
elif aname[-1] == '*':
61
aname = '[' + aname[:-1] + '...]'
70
def print_command_plugin(cmd_object, outfile, format):
71
"""Print the plugin that provides a command object, if any.
73
If the cmd_object is provided by a plugin, prints the plugin name to
74
outfile using the provided format string.
76
plugin_name = cmd_object.plugin_name()
77
if plugin_name is not None:
78
out_str = '(From plugin "%s")' % plugin_name
79
outfile.write(format % out_str)
82
def help_on_command(cmdname, outfile=None):
83
cmdname = str(cmdname)
84
cmd_object = _mod_commands.get_cmd_object(cmdname)
86
return help_on_command_object(cmd_object, cmdname, outfile)
89
def help_on_command_object(cmd_object, cmdname, outfile=None):
90
"""Generate help on the cmd_object with a supplied name of cmdname.
92
:param cmd_object: An instance of a Command.
93
:param cmdname: The user supplied name. This might be an alias for example.
94
:param outfile: A stream to write the help to.
99
doc = cmd_object.help()
101
raise NotImplementedError("sorry, no detailed help yet for %r" % cmdname)
103
print >>outfile, 'usage:', command_usage(cmd_object)
105
if cmd_object.aliases:
106
print >>outfile, 'aliases:',
107
print >>outfile, ', '.join(cmd_object.aliases)
111
print_command_plugin(cmd_object, outfile, '%s\n\n')
116
help_on_command_options(cmd_object, outfile)
117
see_also = cmd_object.get_see_also()
119
outfile.write('\nSee also: ')
120
outfile.write(', '.join(see_also))
124
def help_on_command_options(cmd, outfile=None):
125
from bzrlib.option import Option, get_optparser
128
options = cmd.options()
130
outfile.write(get_optparser(options).format_option_help())
46
cmd_object = _mod_commands.get_cmd_object(cmdname)
47
outfile.write(cmd_object.get_help_text())
133
50
def help_commands(outfile=None):