2 # -*- coding: utf-8 -*-
4 from __future__
import (absolute_import
, division
, print_function
,
9 from stgit
import argparse
, commands
, completion
13 op
= optparse
.OptionParser()
14 op
.add_option('--asciidoc', metavar
= 'CMD',
15 help = 'Print asciidoc documentation for a command')
16 op
.add_option('--commands', action
= 'store_true',
17 help = 'Print list of all stg subcommands')
18 op
.add_option('--cmd-list', action
= 'store_true',
19 help = 'Print asciidoc command list')
20 op
.add_option('--py-cmd-list', action
= 'store_true',
21 help = 'Write Python command list')
22 op
.add_option('--bash-completion', action
= 'store_true',
23 help = 'Write bash completion code')
24 options
, args
= op
.parse_args()
26 op
.error('Wrong number of arguments')
28 argparse
.write_asciidoc(stgit
.main
.commands
[options
.asciidoc
],
30 elif options
.commands
:
31 for cmd
in sorted(commands
.get_commands(allow_cached
=False)):
33 elif options
.cmd_list
:
34 commands
.asciidoc_command_list(
35 commands
.get_commands(allow_cached
= False), sys
.stdout
)
36 elif options
.py_cmd_list
:
37 commands
.py_commands(commands
.get_commands(allow_cached
= False),
39 elif options
.bash_completion
:
40 completion
.write_completion(sys
.stdout
)
42 op
.error('No command')
44 if __name__
== '__main__':