20
20
# executable files with reasonable names.
22
22
# TODO: `help commands --all` should show hidden commands
24
from bzrlib import osutils
27
"""Bazaar -- a free distributed version-control tool
28
http://bazaar-vcs.org/
32
bzr init makes this directory a versioned branch
33
bzr branch make a copy of another branch
35
bzr add make files or directories versioned
36
bzr ignore ignore a file or pattern
37
bzr mv move or rename a versioned file
39
bzr status summarize changes in working copy
40
bzr diff show detailed diffs
42
bzr merge pull in changes from another branch
43
bzr commit save some or all changes
45
bzr log show history of changes
46
bzr check validate storage
48
bzr help init more help on e.g. init command
49
bzr help commands list all commands
56
def help(topic=None, outfile = None):
33
def help(topic=None, outfile=None):
34
"""Write the help for the specific topic to outfile"""
57
35
if outfile is None:
58
36
outfile = sys.stdout
60
outfile.write(global_help)
61
elif topic == 'commands':
62
help_commands(outfile = outfile)
41
if topic in help_topics.topic_registry:
42
txt = help_topics.topic_registry.get_detail(topic)
64
help_on_command(topic, outfile = outfile)
45
help_on_command(topic, outfile=outfile)
67
48
def command_usage(cmd_object):
113
94
raise NotImplementedError("sorry, no detailed help yet for %r" % cmdname)
115
print >>outfile, 'usage:', command_usage(cmd_object)
96
print >>outfile, 'usage:', command_usage(cmd_object)
117
98
if cmd_object.aliases:
118
99
print >>outfile, 'aliases:',
140
121
def help_commands(outfile=None):
141
122
"""List all commands"""
125
outfile.write(_help_commands_to_text('commands'))
128
def _help_commands_to_text(topic):
129
"""Generate the help text for the list of commands"""
142
130
from bzrlib.commands import (builtin_command_names,
143
131
plugin_command_names,
147
135
names = set(builtin_command_names()) # to eliminate duplicates
148
136
names.update(plugin_command_names())
149
137
commands = ((n, get_cmd_object(n)) for n in names)
151
139
max_name = max(len(n) for n, o in shown_commands)
152
140
indent = ' ' * (max_name + 1)
153
141
width = osutils.terminal_width() - 1
154
143
for cmd_name, cmd_object in sorted(shown_commands):
155
144
plugin_name = cmd_object.plugin_name()
156
145
if plugin_name is None:
167
156
lines = textwrap.wrap(helpstring, subsequent_indent=indent,
169
158
for line in lines:
170
outfile.write(line + '\n')
159
out.append(line + '\n')
163
help_topics.topic_registry.register("commands",
164
_help_commands_to_text,
165
"Basic help for all commands")