~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: Robert Collins
  • Date: 2005-10-15 11:38:29 UTC
  • mfrom: (1185.16.40)
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051015113829-40226233fb246920
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
 
    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()
 
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
    
121
122
    if not options:
122
123
        return
 
124
    
123
125
    if outfile == None:
124
126
        outfile = sys.stdout
 
127
 
125
128
    outfile.write('\noptions:\n')
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
 
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
137
135
        outfile.write(l + '\n')
138
136
 
139
137