source: soft/build_system/build_system/repsys/tags/V1_6_16/repsys @ 1

Last change on this file since 1 was 1, checked in by fasma, 13 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 1.9 KB
RevLine 
[1]1#!/usr/bin/python
2from RepSys import Error, plugins
3from RepSys.command import *
4import getopt
5import sys
6
7VERSION="1.6.16"
8
9HELP = """\
10Usage: repsys COMMAND [COMMAND ARGUMENTS]
11
12Useful commands:
13    co
14    submit
15    create
16    getspec
17    getsrpm
18    rpmlog
19    changed
20    authoremail
21    putsrpm
22
23Run "repsys COMMAND --help" for more information.
24
25Run "repsys --help-plugins" for help on loaded plugins.
26
27Written by Gustavo Niemeyer <gustavo@niemeyer.net>
28"""
29
30def plugin_help(opt, val, parser, mode):
31    if parser is None:
32        prog = sys.argv[0]
33        print "Use %s --help-plugin <plugin name>" % prog
34        print "Available plugins:"
35        print
36        for name in plugins.list():
37            print name
38    else:
39        print plugins.help(parser)
40    raise SystemExit
41
42def parse_options():
43    parser = OptionParser(help=HELP, version="%prog "+VERSION)
44    parser.disable_interspersed_args()
45    parser.add_option("--debug", action="store_true")
46    parser.add_option("--help-plugins", action="callback", callback=plugin_help)
47    parser.add_option("--help-plugin", type="string", dest="__ignore",
48            action="callback", callback=plugin_help)
49    opts, args = parser.parse_args()
50    del opts.__ignore
51    if len(args) < 1:
52        parser.print_help(sys.stderr)
53        sys.exit(1)
54    opts.command = args[0]
55    opts.argv = args
56    return opts
57
58def dispatch_command(command, argv, debug=0):
59    sys.argv = argv
60    try:
61        repsys_module = __import__("RepSys.commands."+command)
62        commands_module = getattr(repsys_module, "commands")
63        command_module = getattr(commands_module, command)
64    except (ImportError, AttributeError):
65        if debug:
66            import traceback
67            traceback.print_exc()
68            sys.exit(1)
69        raise Error, "invalid command '%s'" % command
70    command_module.main()
71   
72if __name__ == "__main__":
73    plugins.load()
74    do_command(parse_options, dispatch_command)
75
76# vim:et:ts=4:sw=4
Note: See TracBrowser for help on using the repository browser.