Commit | Line | Data |
---|---|---|
575bbdae KH |
1 | #!/usr/bin/env python |
2 | # -*- python -*- | |
3 | import optparse, sys | |
4 | import stgit.main | |
6c8a90e1 | 5 | from stgit import argparse, commands, completion |
575bbdae KH |
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') | |
33ff9cdd KH |
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') | |
6c8a90e1 KH |
17 | op.add_option('--bash-completion', action = 'store_true', |
18 | help = 'Write bash completion code') | |
575bbdae KH |
19 | options, args = op.parse_args() |
20 | if args: | |
21 | op.error('Wrong number of arguments') | |
22 | if options.asciidoc: | |
23 | argparse.write_asciidoc(stgit.main.commands[options.asciidoc], | |
24 | sys.stdout) | |
25 | elif options.commands: | |
33ff9cdd KH |
26 | for cmd in sorted(commands.get_commands( |
27 | allow_cached = False).iterkeys()): | |
575bbdae | 28 | print cmd |
33ff9cdd KH |
29 | elif options.cmd_list: |
30 | commands.asciidoc_command_list( | |
31 | commands.get_commands(allow_cached = False), sys.stdout) | |
32 | elif options.py_cmd_list: | |
33 | commands.py_commands(commands.get_commands(allow_cached = False), | |
34 | sys.stdout) | |
6c8a90e1 KH |
35 | elif options.bash_completion: |
36 | completion.write_completion(sys.stdout) | |
575bbdae KH |
37 | else: |
38 | op.error('No command') | |
39 | ||
40 | if __name__ == '__main__': | |
41 | main() |