Move stack reset function to a shared location
[stgit] / stg-build
1 #!/usr/bin/env python
2 # -*- python -*-
3 import optparse, sys
4 import stgit.main
5 from stgit import argparse, commands
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 op.add_option('--cmd-list', action = 'store_true',
14 help = 'Print asciidoc command list')
15 op.add_option('--py-cmd-list', action = 'store_true',
16 help = 'Write Python command list')
17 options, args = op.parse_args()
18 if args:
19 op.error('Wrong number of arguments')
20 if options.asciidoc:
21 argparse.write_asciidoc(stgit.main.commands[options.asciidoc],
22 sys.stdout)
23 elif options.commands:
24 for cmd in sorted(commands.get_commands(
25 allow_cached = False).iterkeys()):
26 print cmd
27 elif options.cmd_list:
28 commands.asciidoc_command_list(
29 commands.get_commands(allow_cached = False), sys.stdout)
30 elif options.py_cmd_list:
31 commands.py_commands(commands.get_commands(allow_cached = False),
32 sys.stdout)
33 else:
34 op.error('No command')
35
36 if __name__ == '__main__':
37 main()