5 from stgit
import argparse
, commands
, completion
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 op
.add_option('--bash-completion', action
= 'store_true',
18 help = 'Write bash completion code')
19 options
, args
= op
.parse_args()
21 op
.error('Wrong number of arguments')
23 argparse
.write_asciidoc(stgit
.main
.commands
[options
.asciidoc
],
25 elif options
.commands
:
26 for cmd
in sorted(commands
.get_commands(
27 allow_cached
= False).iterkeys()):
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),
35 elif options
.bash_completion
:
36 completion
.write_completion(sys
.stdout
)
38 op
.error('No command')
40 if __name__
== '__main__':