~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
 
 
19
17
# TODO: Some way to get a list of external commands (defined by shell
20
18
# scripts) so that they can be included in the help listing as well.
21
19
# It should be enough to just list the plugin directory and look for
24
22
# TODO: `help commands --all` should show hidden commands
25
23
 
26
24
import sys
 
25
import textwrap
27
26
 
28
27
from bzrlib import (
29
28
    commands as _mod_commands,
31
30
    help_topics,
32
31
    osutils,
33
32
    plugin,
34
 
    ui,
35
 
    utextwrap,
 
33
    symbol_versioning,
36
34
    )
37
35
 
38
36
 
39
37
def help(topic=None, outfile=None):
40
38
    """Write the help for the specific topic to outfile"""
41
39
    if outfile is None:
42
 
        outfile = ui.ui_factory.make_output_stream()
 
40
        outfile = sys.stdout
43
41
 
44
42
    indices = HelpIndices()
45
43
 
47
45
    try:
48
46
        topics = indices.search(topic)
49
47
        shadowed_terms = []
50
 
        for index, topic_obj in topics[1:]:
 
48
        for index, topic in topics[1:]:
51
49
            shadowed_terms.append('%s%s' % (index.prefix,
52
 
                topic_obj.get_help_topic()))
 
50
                topic.get_help_topic()))
53
51
        source = topics[0][1]
54
52
        outfile.write(source.get_help_text(shadowed_terms))
55
53
    except errors.NoHelpTopic:
64
62
def help_commands(outfile=None):
65
63
    """List all commands"""
66
64
    if outfile is None:
67
 
        outfile = ui.ui_factory.make_output_stream()
 
65
        outfile = sys.stdout
68
66
    outfile.write(_help_commands_to_text('commands'))
69
67
 
70
68
 
99
97
        else:
100
98
            firstline = ''
101
99
        helpstring = '%-*s %s%s' % (max_name, cmd_name, firstline, plugin_name)
102
 
        lines = utextwrap.wrap(
 
100
        lines = textwrap.wrap(
103
101
            helpstring, subsequent_indent=indent,
104
102
            width=width,
105
103
            break_long_words=False)
138
136
            help_topics.HelpTopicIndex(),
139
137
            _mod_commands.HelpCommandIndex(),
140
138
            plugin.PluginsHelpIndex(),
141
 
            help_topics.ConfigOptionHelpIndex(),
142
139
            ]
143
140
 
144
141
    def _check_prefix_uniqueness(self):