~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

Implement ParamikoVendor.connect_ssh

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
 
55
55
def help(topic=None, outfile = None):
56
 
    if outfile == None:
 
56
    if outfile is None:
57
57
        outfile = sys.stdout
58
 
    if topic == None:
 
58
    if topic is None:
59
59
        outfile.write(global_help)
60
60
    elif topic == 'commands':
61
61
        help_commands(outfile = outfile)
102
102
 
103
103
    cmdname = str(cmdname)
104
104
 
105
 
    if outfile == None:
 
105
    if outfile is None:
106
106
        outfile = sys.stdout
107
107
 
108
108
    cmd_object = get_cmd_object(cmdname)
109
109
 
110
110
    doc = cmd_object.help()
111
 
    if doc == None:
 
111
    if doc is None:
112
112
        raise NotImplementedError("sorry, no detailed help yet for %r" % cmdname)
113
113
 
114
114
    print >>outfile, 'usage:', command_usage(cmd_object) 
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):
156
142
                                 plugin_command_names,
157
143
                                 get_cmd_object)
158
144
 
159
 
    if outfile == None:
 
145
    if outfile is None:
160
146
        outfile = sys.stdout
161
147
 
162
148
    names = set()                       # to eliminate duplicates