~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-30 04:33:35 UTC
  • mto: (1711.2.26 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1734.
  • Revision ID: john@arbash-meinel.com-20060530043335-2c754880fbbe2950
Add tests for fancy file types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005 by Canonical Ltd
 
1
# Copyright (C) 2004, 2005, 2006 by Canonical Ltd
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
# executable files with reasonable names.
21
21
 
22
22
# TODO: `help commands --all` should show hidden commands
 
23
import textwrap
23
24
 
24
25
global_help = \
25
26
"""Bazaar-NG -- a free distributed version-control tool
26
 
http://bazaar-ng.org/
27
 
 
28
 
WARNING: This is an unstable development version.
29
 
         Please keep backups.
 
27
http://bazaar-vcs.org/
30
28
 
31
29
Basic commands:
32
30
 
33
 
  bzr init      makes this branch versioned
34
 
  bzr branch    make a copy of another branch
35
 
 
36
 
  bzr add       make files or directories versioned
37
 
  bzr ignore    ignore a file or pattern
38
 
  bzr mv        move or rename a versioned file
39
 
 
40
 
  bzr status    summarize changes in working copy
41
 
  bzr diff      show detailed diffs
42
 
 
43
 
  bzr merge     pull in changes from another branch
44
 
  bzr commit    
45
 
 
46
 
  bzr log       show history of changes
47
 
  bzr check     validate storage
48
 
 
49
 
Use e.g. 'bzr help init' for more details, or
50
 
'bzr help commands' for all commands.
 
31
  bzr init           makes this directory a versioned branch
 
32
  bzr branch         make a copy of another branch
 
33
 
 
34
  bzr add            make files or directories versioned
 
35
  bzr ignore         ignore a file or pattern
 
36
  bzr mv             move or rename a versioned file
 
37
 
 
38
  bzr status         summarize changes in working copy
 
39
  bzr diff           show detailed diffs
 
40
 
 
41
  bzr merge          pull in changes from another branch
 
42
  bzr commit         save some or all changes
 
43
 
 
44
  bzr log            show history of changes
 
45
  bzr check          validate storage
 
46
 
 
47
  bzr help init      more help on e.g. init command
 
48
  bzr help commands  list all commands
51
49
"""
52
50
 
53
51
 
112
110
    outfile.write(doc)
113
111
    if doc[-1] != '\n':
114
112
        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
 
    
 
113
    help_on_command_options(cmd_object, outfile)
 
114
 
 
115
 
 
116
def help_on_command_options(cmd, outfile=None):
 
117
    from bzrlib.option import Option
 
118
    options = cmd.options()
122
119
    if not options:
123
120
        return
124
 
    
125
121
    if outfile == None:
126
122
        outfile = sys.stdout
127
 
 
128
123
    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
135
 
        outfile.write(l + '\n')
 
124
    for option_name, option in sorted(options.items()):
 
125
        l = '    --' + option_name
 
126
        if option.type is not None:
 
127
            l += ' ' + option.argname.upper()
 
128
        short_name = option.short_name()
 
129
        if short_name:
 
130
            assert len(short_name) == 1
 
131
            l += ', -' + short_name
 
132
        l += (30 - len(l)) * ' ' + option.help
 
133
        # TODO: split help over multiple lines with correct indenting and 
 
134
        # wrapping
 
135
        wrapped = textwrap.fill(l, initial_indent='', subsequent_indent=30*' ')
 
136
        outfile.write(wrapped + '\n')
136
137
 
137
138
 
138
139
def help_commands(outfile=None):
158
159
        cmd_help = cmd_object.help()
159
160
        if cmd_help:
160
161
            firstline = cmd_help.split('\n', 1)[0]
161
 
            print >>outfile, '    ' + firstline
 
162
            print >>outfile, '        ' + firstline
162
163