~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: Robert J. Tanner
  • Date: 2009-06-10 03:56:49 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4425.
  • Revision ID: tanner@real-time.com-20090610035649-7rfx4cls4550zc3c
Merge 1.15.1 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
        hidden = True
74
74
    else:
75
75
        hidden = False
76
 
    names = list(_mod_commands.all_command_names())
 
76
    names = set(_mod_commands.builtin_command_names()) # to eliminate duplicates
 
77
    names.update(_mod_commands.plugin_command_names())
77
78
    commands = ((n, _mod_commands.get_cmd_object(n)) for n in names)
78
79
    shown_commands = [(n, o) for n, o in commands if o.hidden == hidden]
79
80
    max_name = max(len(n) for n, o in shown_commands)
80
81
    indent = ' ' * (max_name + 1)
81
 
    width = osutils.terminal_width()
82
 
    if width is None:
83
 
        width = osutils.default_terminal_width
84
 
    # we need one extra space for terminals that wrap on last char
85
 
    width = width - 1
 
82
    width = osutils.terminal_width() - 1
86
83
 
87
84
    for cmd_name, cmd_object in sorted(shown_commands):
88
85
        plugin_name = cmd_object.plugin_name()
97
94
        else:
98
95
            firstline = ''
99
96
        helpstring = '%-*s %s%s' % (max_name, cmd_name, firstline, plugin_name)
100
 
        lines = textwrap.wrap(
101
 
            helpstring, subsequent_indent=indent,
102
 
            width=width,
103
 
            break_long_words=False)
 
97
        lines = textwrap.wrap(helpstring, subsequent_indent=indent,
 
98
                              width=width)
104
99
        for line in lines:
105
100
            out.append(line + '\n')
106
101
    return ''.join(out)