17
16
# along with this program; if not, write to the Free Software
18
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
"""big_man.py - create man page from built-in bzr help and static text
22
* use usage information instead of simple "bzr foo" in COMMAND OVERVIEW
21
27
import bzrlib, bzrlib.help, bzrlib.commands
22
#<<< Begin (C) Hans Ulrich Niedermann
32
def get_filename(options):
33
return "%s.1" % (options.bzr_name)
36
def infogen(options, outfile):
28
38
tt = time.gmtime(t)
40
{ "bzrcmd": options.bzr_name,
31
41
"datestamp": time.strftime("%Y-%m-%d",tt),
32
42
"timestamp": time.strftime("%Y-%m-%d %H:%M:%S +0000",tt),
33
43
"version": bzrlib.__version__,
37
if len(sys.argv) == 2:
38
filename = sys.argv[1]
42
outfile = open(filename,"w")
44
46
outfile.write(man_preamble % params)
45
47
outfile.write(man_escape(man_head % params))
46
#<<< End (C) Hans Ulrich Niedermann
47
outfile.write(man_escape(getcommand_help()))
48
#<<< Begin (C) Hans Ulrich Niedermann
49
outfile.write(man_escape(getcommand_list(params)))
50
outfile.write(man_escape(getcommand_help(params)))
49
52
outfile.write(man_escape(man_foot % params))
51
55
def man_escape(string):
52
56
result = string.replace("\\","\\\\")
53
57
result = result.replace("`","\\`")
54
58
result = result.replace("'","\\'")
55
59
result = result.replace("-","\\-")
57
#<<< End (C) Hans Ulrich Niedermann
59
def format_command (cmd):
60
cmdusage = '.TP\n.B %s\n.PP\n' % (bzrlib.help.command_usage(cmd))
61
doc = "%s\n.PP\n.PP\n" % (cmd.__doc__)
64
def getcommand_help():
63
def command_name_list():
66
64
command_names = bzrlib.commands.builtin_command_names()
67
65
command_names.sort()
68
for cmd_name in command_names:
69
desc = bzrlib.commands.get_cmd_object(cmd_name)
70
output = output + format_command(desc)
69
def getcommand_list (params):
70
bzrcmd = params["bzrcmd"]
71
output = '.SH "COMMAND OVERVIEW"\n'
72
for cmd_name in command_name_list():
73
cmd_object = bzrlib.commands.get_cmd_object(cmd_name)
76
cmd_help = cmd_object.help()
78
firstline = cmd_help.split('\n', 1)[0]
79
tmp = '.TP\n.B "%s %s"\n%s\n' % (bzrcmd, cmd_name,
83
raise RuntimeError, "Command '%s' has no help text" % (cmd_name)
87
def format_command (params, cmd):
88
subsection_header = '.SS "%s %s"\n' % (params["bzrcmd"], cmd.name())
89
cmdusage = '.TP\n.B "Usage: %s"\n.PP\n' % (bzrlib.help.command_usage(cmd))
90
doc = "%s\n" % (cmd.__doc__)
92
options = cmd.options()
93
# option walk code stolen from bzrlib/help.py
95
option_str = "\nOptions:\n"
96
for option_name, option in sorted(options.items()):
97
l = ' --' + option_name
98
if option.type is not None:
99
l += ' ' + option.argname.upper()
100
short_name = option.short_name()
102
assert len(short_name) == 1
103
l += ', -' + short_name
104
l += (30 - len(l)) * ' ' + option.help
105
# TODO: split help over multiple lines with correct indenting and
107
wrapped = textwrap.fill(l, initial_indent='',
108
subsequent_indent=30*' ')
109
option_str = option_str + wrapped + '\n'
110
return subsection_header + cmdusage + doc + option_str
113
def getcommand_help(params):
114
output='.SH "COMMAND REFERENCE"\n'
115
for cmd_name in command_name_list():
116
cmd_object = bzrlib.commands.get_cmd_object(cmd_name)
117
if cmd_object.hidden:
119
output = output + format_command(params, cmd_object)
94
143
) is a project of Canonical Ltd. to develop an open source distributed version control system that is powerful, friendly, and scalable. Version control means a system that keeps track of previous revisions of software source code or similar information and helps people work on it in teams.
96
145
bazaar-ng is at an early stage of development, and the design is still changing from week to week. This man page here may be inconsistent with itself, with other documentation or with the code, and sometimes refer to features that are planned but not yet written. Comments are still very welcome; please send them to bazaar-ng@lists.canonical.com.
148
Commands for a number of common use cases.
150
.SS "Create a branch"
154
.SS "Add files to be versioned"
156
$ %(bzrcmd)s add hello-world.c Makefile
158
.SS "Review local changes"
163
.SS "Commit changes to branch"
165
$ %(bzrcmd)s commit -m \"initial import of files\"
167
.SS "Branching off an existing branch"
168
$ %(bzrcmd)s branch http://other.com/project-foo
171
$ %(bzrcmd)s branch http://other.com/project-foo foo-by-other
174
$ %(bzrcmd)s branch foo-by-other foo-with-my-changes
175
$ cd foo-with-my-changes
177
.SS "Following upstream changes"
178
If you have not modified anything in your local branch:
182
If you have modified and committed things in your local branch:
183
$ cd foo-with-my-changes
186
.SS "Publishing your changes"
187
Publishing your branch for the first time:
188
$ cd foo-with-my-changes
189
$ %(bzrcmd)s push sftp://user@host/public_html/foo-with-my-changes
191
Publishing your branch subsequently is easier as %(bzrcmd)s remembers the push location:
192
$ cd foo-with-my-changes