diff options
Diffstat (limited to 'repsys')
-rwxr-xr-x | repsys | 34 |
1 files changed, 32 insertions, 2 deletions
@@ -1,18 +1,21 @@ #!/usr/bin/python -from RepSys import Error +from RepSys import Error, plugins from RepSys.command import * import getopt import sys +import codecs +import locale VERSION="1.7.r%s" % ("$Rev$".split()[-2].strip()) HELP = """\ -$Id$ Usage: repsys COMMAND [COMMAND ARGUMENTS] Useful commands: co + sync + ci submit create getspec @@ -20,17 +23,36 @@ Useful commands: rpmlog changed authoremail + putsrpm Run "repsys COMMAND --help" for more information. +Run "repsys --help-plugins" for help on loaded plugins. + Written by Gustavo Niemeyer <gustavo@niemeyer.net> """ +def plugin_help(opt, val, parser, mode): + if parser is None: + prog = sys.argv[0] + print "Use %s --help-plugin <plugin name>" % prog + print "Available plugins:" + print + for name in plugins.list(): + print name + else: + print plugins.help(parser) + raise SystemExit + def parse_options(): parser = OptionParser(help=HELP, version="%prog "+VERSION) parser.disable_interspersed_args() parser.add_option("--debug", action="store_true") + parser.add_option("--help-plugins", action="callback", callback=plugin_help) + parser.add_option("--help-plugin", type="string", dest="__ignore", + action="callback", callback=plugin_help) opts, args = parser.parse_args() + del opts.__ignore if len(args) < 1: parser.print_help(sys.stderr) sys.exit(1) @@ -53,6 +75,14 @@ def dispatch_command(command, argv, debug=0): command_module.main() if __name__ == "__main__": + try: + plugins.load() + except Error, e: + sys.stderr.write("plugin initialization error: %s\n" % e) + sys.exit(1) + encoding = locale.getpreferredencoding() + sys.stdout = codecs.getwriter(encoding)(sys.stdout, errors="replace") + sys.stderr = codecs.getwriter(encoding)(sys.stderr, errors="replace") do_command(parse_options, dispatch_command) # vim:et:ts=4:sw=4 |