~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-16 22:00:19 UTC
  • mto: This revision was merged to the branch mainline in revision 1942.
  • Revision ID: john@arbash-meinel.com-20060816220019-541cb90093258ac3
Using real utf8 and cache_utf8 has similar performance, 272ms, and 363ms

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2004, 2005, 2006 by 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
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
23
import textwrap
24
24
 
25
25
global_help = \
26
 
"""Bazaar-NG -- a free distributed version-control tool
 
26
"""Bazaar -- a free distributed version-control tool
27
27
http://bazaar-vcs.org/
28
28
 
29
29
Basic commands:
128
128
 
129
129
 
130
130
def help_on_command_options(cmd, outfile=None):
131
 
    from bzrlib.option import Option
 
131
    from bzrlib.option import Option, get_optparser
 
132
    if outfile is None:
 
133
        outfile = sys.stdout
132
134
    options = cmd.options()
133
 
    if not options:
134
 
        return
135
 
    if outfile == None:
136
 
        outfile = sys.stdout
137
 
    outfile.write('\noptions:\n')
138
 
    for option_name, option in sorted(options.items()):
139
 
        l = '    --' + option_name
140
 
        if option.type is not None:
141
 
            l += ' ' + option.argname.upper()
142
 
        short_name = option.short_name()
143
 
        if short_name:
144
 
            assert len(short_name) == 1
145
 
            l += ', -' + short_name
146
 
        l += (30 - len(l)) * ' ' + option.help
147
 
        # TODO: split help over multiple lines with correct indenting and 
148
 
        # wrapping
149
 
        wrapped = textwrap.fill(l, initial_indent='', subsequent_indent=30*' ')
150
 
        outfile.write(wrapped + '\n')
 
135
    outfile.write('\n')
 
136
    outfile.write(get_optparser(options).format_option_help())
151
137
 
152
138
 
153
139
def help_commands(outfile=None):