File: stg-build

package info (click to toggle)
stgit 0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,752 kB
  • sloc: python: 10,558; sh: 5,739; lisp: 2,678; makefile: 142; perl: 42
file content (45 lines) | stat: -rwxr-xr-x 1,688 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- python -*-
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
import optparse
import sys
import stgit.main
from stgit import argparse, commands, completion


def main():
    op = optparse.OptionParser()
    op.add_option('--asciidoc', metavar = 'CMD',
                  help = 'Print asciidoc documentation for a command')
    op.add_option('--commands', action = 'store_true',
                  help = 'Print list of all stg subcommands')
    op.add_option('--cmd-list', action = 'store_true',
                  help = 'Print asciidoc command list')
    op.add_option('--py-cmd-list', action = 'store_true',
                  help = 'Write Python command list')
    op.add_option('--bash-completion', action = 'store_true',
                  help = 'Write bash completion code')
    options, args = op.parse_args()
    if args:
        op.error('Wrong number of arguments')
    if options.asciidoc:
        argparse.write_asciidoc(stgit.main.commands[options.asciidoc],
                                sys.stdout)
    elif options.commands:
        for cmd in sorted(commands.get_commands(allow_cached=False)):
            print(cmd)
    elif options.cmd_list:
        commands.asciidoc_command_list(
            commands.get_commands(allow_cached = False), sys.stdout)
    elif options.py_cmd_list:
        commands.py_commands(commands.get_commands(allow_cached = False),
                             sys.stdout)
    elif options.bash_completion:
        completion.write_completion(sys.stdout)
    else:
        op.error('No command')

if __name__ == '__main__':
    main()