141
142
from bzrlib.commands import (builtin_command_names,
142
143
plugin_command_names,
145
145
if outfile is None:
146
146
outfile = sys.stdout
148
names = set() # to eliminate duplicates
149
names.update(builtin_command_names())
147
names = set(builtin_command_names()) # to eliminate duplicates
150
148
names.update(plugin_command_names())
154
for cmd_name in names:
155
cmd_object = get_cmd_object(cmd_name)
156
if cmd_object.hidden:
158
print >>outfile, command_usage(cmd_object)
149
commands = ((n, get_cmd_object(n)) for n in names)
150
shown_commands = [(n, o) for n, o in commands if not o.hidden]
151
max_name = max(len(n) for n, o in shown_commands)
152
indent = ' ' * (max_name + 1)
153
width = osutils.terminal_width() - 1
154
for cmd_name, cmd_object in sorted(shown_commands):
160
155
plugin_name = cmd_object.plugin_name()
161
print_command_plugin(cmd_object, outfile, ' %s\n')
156
if plugin_name is None:
159
plugin_name = ' [%s]' % plugin_name
163
161
cmd_help = cmd_object.help()
165
163
firstline = cmd_help.split('\n', 1)[0]
166
print >>outfile, ' ' + firstline
166
helpstring = '%-*s %s%s' % (max_name, cmd_name, firstline, plugin_name)
167
lines = textwrap.wrap(helpstring, subsequent_indent=indent,
170
outfile.write(line + '\n')