~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: ghigo
  • Date: 2006-09-20 20:59:27 UTC
  • mto: (2070.4.1 help-topics)
  • mto: This revision was merged to the branch mainline in revision 2126.
  • Revision ID: ghigo@venice-20060920205927-6ae24018d7b8c33c
add topics help

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# executable files with reasonable names.
21
21
 
22
22
# TODO: `help commands --all` should show hidden commands
23
 
import textwrap
24
 
 
25
 
global_help = \
26
 
"""Bazaar -- a free distributed version-control tool
27
 
http://bazaar-vcs.org/
28
 
 
29
 
Basic commands:
30
 
 
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
49
 
"""
50
 
 
51
23
 
52
24
import sys
53
25
 
54
 
 
55
 
def help(topic=None, outfile = None):
 
26
from bzrlib import help_topics
 
27
 
 
28
 
 
29
help_topics.add_topic("commands",
 
30
                      (lambda name, outfile: help_commands(outfile)),
 
31
                      "Basic help for all commands")
 
32
 
 
33
 
 
34
def help(topic=None, outfile=None):
 
35
    """Print out the help for a specific topic or command."""
 
36
 
56
37
    if outfile is None:
57
38
        outfile = sys.stdout
58
39
    if topic is None:
59
 
        outfile.write(global_help)
60
 
    elif topic == 'commands':
61
 
        help_commands(outfile = outfile)
 
40
        help_topics.write_topic("basic", outfile)
 
41
    elif help_topics.is_topic(topic):
 
42
        help_topics.write_topic(topic, outfile)
62
43
    else:
63
 
        help_on_command(topic, outfile = outfile)
 
44
        help_on_command(topic, outfile=outfile)
64
45
 
65
46
 
66
47
def command_usage(cmd_object):
164
145
        if cmd_help:
165
146
            firstline = cmd_help.split('\n', 1)[0]
166
147
            print >>outfile, '        ' + firstline
167
 
        
 
148