~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-17 13:53:36 UTC
  • mfrom: (1939 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1940.
  • Revision ID: john@arbash-meinel.com-20060817135336-100de82962355d3b
[merge] bzr.dev 1939

Show diffs side-by-side

added added

removed removed

Lines of Context:
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):