Auto-generate man pages for all StGit commands
[stgit] / stg-build
1 #!/usr/bin/env python
2 # -*- python -*-
3 import optparse, sys
4 import stgit.main
5 from stgit import argparse
6
7 def main():
8 op = optparse.OptionParser()
9 op.add_option('--asciidoc', metavar = 'CMD',
10 help = 'Print asciidoc documentation for a command')
11 op.add_option('--commands', action = 'store_true',
12 help = 'Print list of all stg subcommands')
13 options, args = op.parse_args()
14 if args:
15 op.error('Wrong number of arguments')
16 if options.asciidoc:
17 argparse.write_asciidoc(stgit.main.commands[options.asciidoc],
18 sys.stdout)
19 elif options.commands:
20 for cmd in sorted(stgit.main.commands.iterkeys()):
21 print cmd
22 else:
23 op.error('No command')
24
25 if __name__ == '__main__':
26 main()