import optparse import os from wizard.command import _command # submodules import list import list_errors import version import count_exists def main(argv, baton): usage = """usage: %prog summary [ARGS] APPS Scans all of the collected data from parallel-find.pl, and calculates interesting information about them. Its subcommands are: count-exists Counts how many autoinstalls contain a file list Prints the locations of all autoinstalls list-errors Prints all errors that occurred during parsing version Breakdown of autoinstalls by version (default) Use %prog summary SUBCOMMAND --help for more information.""" parser = _command.WizardOptionParser(usage) parser.disable_interspersed_args() baton.push(parser, "versions_path") _, args = parser.parse_all(argv) rest_argv = args[1:] try: command = args[0] except IndexError: command = "version" def get_command(name): return globals()[name.replace("-", "_")] if command == "help": try: get_command(rest_argv[0]).main(['--help'], baton) except KeyError: parser.error("invalid action") except IndexError: parser.print_help() raise SystemExit(1) try: command_module = get_command(command) except KeyError: parser.error("invalid action") command_module.main(rest_argv, baton)