~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
    outfile.write(doc)
113
113
    if doc[-1] != '\n':
114
114
        outfile.write('\n')
115
 
    
116
 
    help_on_options(cmd_object.takes_options, outfile=None)
117
 
 
118
 
 
119
 
def help_on_options(options, outfile=None):
120
 
    from bzrlib.commands import SHORT_OPTIONS
121
 
    
 
115
    help_on_command_options(cmd_object, outfile=None)
 
116
 
 
117
 
 
118
def help_on_command_options(cmd, outfile=None):
 
119
    from bzrlib.option import Option
 
120
    options = cmd.options()
122
121
    if not options:
123
122
        return
124
 
    
125
123
    if outfile == None:
126
124
        outfile = sys.stdout
127
 
 
128
125
    outfile.write('\noptions:\n')
129
 
    for on in options:
130
 
        l = '    --' + on
131
 
        for shortname, longname in SHORT_OPTIONS.items():
132
 
            if longname == on:
133
 
                l += ', -' + shortname
134
 
                break
 
126
    for option_name, option in sorted(options.items()):
 
127
        l = '    --' + option_name
 
128
        if option.type is not None:
 
129
            l += ' ' + option.argname.upper()
 
130
        short_name = option.short_name()
 
131
        if short_name:
 
132
            assert len(short_name) == 1
 
133
            l += ', -' + shortname
 
134
        l += (30 - len(l)) * ' ' + option.help
 
135
        # TODO: split help over multiple lines with correct indenting and 
 
136
        # wrapping
135
137
        outfile.write(l + '\n')
136
138
 
137
139