~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: Aaron Bentley
  • Date: 2006-09-23 17:28:50 UTC
  • mto: This revision was merged to the branch mainline in revision 2042.
  • Revision ID: aaron.bentley@utoronto.ca-20060923172850-790fb842f3df42fe
Condense command help text

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
# TODO: `help commands --all` should show hidden commands
23
23
import textwrap
 
24
from bzrlib import osutils 
24
25
 
25
26
global_help = \
26
27
"""Bazaar -- a free distributed version-control tool
150
151
    names.update(plugin_command_names())
151
152
    names = list(names)
152
153
    names.sort()
 
154
    commands = [(n, get_cmd_object(n)) for n in names]
153
155
 
 
156
    max_name = max([len(n) for n, o in commands if not o.hidden])
 
157
    format_string = '%%-%ds %%s %%s' % max_name
 
158
    indent = ' ' * (max_name+1)
 
159
    width = osutils.terminal_width() - 1
154
160
    for cmd_name in names:
155
161
        cmd_object = get_cmd_object(cmd_name)
156
162
        if cmd_object.hidden:
157
163
            continue
158
 
        print >>outfile, command_usage(cmd_object)
159
 
 
160
164
        plugin_name = cmd_object.plugin_name()
161
 
        print_command_plugin(cmd_object, outfile, '        %s\n')
 
165
        if plugin_name is None:
 
166
            plugin_name = ''
 
167
        else:
 
168
            plugin_name = '<%s>' % plugin_name
162
169
 
163
170
        cmd_help = cmd_object.help()
164
171
        if cmd_help:
165
172
            firstline = cmd_help.split('\n', 1)[0]
166
 
            print >>outfile, '        ' + firstline
 
173
        else:
 
174
            firstline = ''
 
175
        helpstring = format_string % (cmd_name, firstline, plugin_name)
 
176
        lines = textwrap.wrap(helpstring, subsequent_indent=indent,
 
177
                              width=width)
 
178
        for line in lines:
 
179
            print >> outfile, line
167
180