]> scripts.mit.edu Git - wizard.git/blob - bin/wizard
Move a bunch of summary items to full class commands.
[wizard.git] / bin / wizard
1 #!/usr/bin/env python
2
3 import os
4 import optparse
5 import sys
6
7 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8
9 import wizard
10 from wizard import command
11
12 def main():
13     usage = """usage: %prog COMMAND [ARGS]
14
15 Wizard is a Git-based autoinstall management system for scripts.
16
17 Its commands are:
18     errors          Lists all broken autoinstall metadata
19     info            Reports information about an autoinstall
20     list            Lists autoinstalls, with optional filtering
21     massmigrate     Performs mass migration of autoinstalls of an application
22     migrate         Migrate autoinstalls from old format to Git-based format
23     summary         Generate statistics (see help for subcommands)
24     upgrade         Upgrades an autoinstall to the latest version
25
26 See '%prog help COMMAND' for more information on a specific command."""
27
28     parser = optparse.OptionParser(usage)
29     parser.disable_interspersed_args()
30     _, args = parser.parse_args() # no global options
31     rest_argv = args[1:]
32     baton = command.OptionBaton()
33     baton.add("--versions-path", dest="versions_path",
34         default="/afs/athena.mit.edu/contrib/scripts/sec-tools/store/versions",
35         help="Location of parallel-find output directory, or a file containing a newline separated list of 'all autoinstalls' (for testing).")
36     try:
37         command_name = args[0]
38     except IndexError:
39         parser.print_help()
40         raise SystemExit(1)
41     if command_name == "help":
42         try:
43             get_command(rest_argv[0]).main(['--help'], baton)
44         except (AttributeError, ImportError):
45             parser.error("invalid action")
46         except IndexError:
47             parser.print_help()
48             raise SystemExit(1)
49     # Dispatch commands
50     try:
51         command_module = get_command(command_name)
52     except (AttributeError, ImportError):
53         parser.error("invalid action")
54     command_module.main(rest_argv, baton)
55
56 def get_command(name):
57     __import__("wizard.command." + name)
58     return getattr(wizard.command, name)
59
60 if __name__ == "__main__":
61     main()
62