1
# Copyright (C) 2004, 2005 by Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
"""Bazaar-NG -- a free distributed version-control tool
21
WARNING: This is an unstable development version.
26
bzr init makes this branch versioned
27
bzr branch make a copy of another branch
29
bzr add make files or directories versioned
30
bzr ignore ignore a file or pattern
31
bzr mv move or rename a versioned file
33
bzr status summarize changes in working copy
34
bzr diff show detailed diffs
36
bzr merge pull in changes from another branch
39
bzr log show history of changes
40
bzr check validate storage
42
Use e.g. 'bzr help init' for more details, or
43
'bzr help commands' for all commands.
50
def help(topic=None, outfile = None):
54
outfile.write(global_help)
55
elif topic == 'commands':
56
help_commands(outfile = outfile)
58
help_on_command(topic, outfile = outfile)
61
def command_usage(cmdname, cmdclass):
62
"""Return single-line grammar for command.
64
Only describes arguments, not options.
67
for aname in cmdclass.takes_args:
69
if aname[-1] in ['$', '+']:
70
aname = aname[:-1] + '...'
71
elif aname[-1] == '?':
72
aname = '[' + aname[:-1] + ']'
73
elif aname[-1] == '*':
74
aname = '[' + aname[:-1] + '...]'
83
def help_on_command(cmdname, outfile = None):
84
cmdname = str(cmdname)
89
from inspect import getdoc
91
topic, cmdclass = commands.get_cmd_class(cmdname)
93
doc = getdoc(cmdclass)
95
raise NotImplementedError("sorry, no detailed help yet for %r" % cmdname)
97
outfile.write('usage: ' + command_usage(topic, cmdclass) + '\n')
100
outfile.write('aliases: ' + ', '.join(cmdclass.aliases) + '\n')
106
help_on_option(cmdclass.takes_options, outfile = None)
109
def help_on_option(options, outfile = None):
118
outfile.write('\noptions:\n')
121
for shortname, longname in commands.SHORT_OPTIONS.items():
123
l += ', -' + shortname
125
outfile.write(l + '\n')
128
def help_commands(outfile = None):
129
"""List all commands"""
137
for cmdname, cmdclass in commands.get_all_cmds():
138
accu.append((cmdname, cmdclass))
140
for cmdname, cmdclass in accu:
143
outfile.write(command_usage(cmdname, cmdclass) + '\n')
144
help = inspect.getdoc(cmdclass)
146
outfile.write(" " + help.split('\n', 1)[0] + '\n')