~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: Aaron Bentley
  • Date: 2006-07-12 19:21:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1934.
  • Revision ID: abentley@panoramicfeedback.com-20060712192138-981a109321bd4a5b
Use optparse for generating option help

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
 
130
130
def help_on_command_options(cmd, outfile=None):
131
131
    from bzrlib.option import Option
 
132
    from commands import get_optparser
 
133
    if outfile is None:
 
134
        outfile = sys.stdout
132
135
    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')
 
136
    outfile.write('\n')
 
137
    outfile.write(get_optparser(options).format_option_help())
151
138
 
152
139
 
153
140
def help_commands(outfile=None):