]> scripts.mit.edu Git - wizard.git/blob - bin/wizard
Knock off a whole bunch of TODO items.
[wizard.git] / bin / wizard
1 #!/usr/bin/env python
2
3 import os
4 import optparse
5 import sys
6
7 # Add lib to path
8 sys.path.insert(0,os.path.abspath(os.path.join(__file__,'../../lib')))
9 import wizard.command
10
11 def main():
12     usage = """usage: %prog [-s|--versions] COMMAND [ARGS]
13
14 Wizard is a Git-based autoinstall management system for scripts.
15
16 Its commands are:
17     info            Reports information about an autoinstall
18     massmigrate     Performs mass migration of autoinstalls of an application
19     migrate         Migrate autoinstalls from old format to Git-based format
20     summary         Generate statistics about autoinstalls
21
22 See '%prog help COMMAND' for more information on a specific command."""
23
24     parser = optparse.OptionParser(usage)
25     parser.disable_interspersed_args()
26     parser.add_option("-s", "--versions", dest="versions",
27             default="/afs/athena.mit.edu/contrib/scripts/sec-tools/store/versions",
28             help="Location of parallel-find output directory, or a file containing a newline separated list of 'all autoinstalls' (for testing).")
29     # Find the end of the "global" options
30     options, args = parser.parse_args()
31     rest_argv = args[1:]
32     command = args[0] # shouldn't fail
33     if command == "help":
34         try:
35             getattr(wizard.command, rest_argv[0]).main(['-h'], options)
36         except AttributeError:
37             parser.error("invalid action")
38         except IndexError:
39             parser.print_help()
40             raise SystemExit(-1)
41     # Dispatch commands
42     try:
43         command_module = getattr(wizard.command, command)
44     except AttributeError:
45         parser.error("invalid action")
46     command_module.main(rest_argv, options)
47
48 if __name__ == "__main__":
49     main()
50