]> scripts.mit.edu Git - wizard.git/blob - bin/wizard
4fac5dc63e36ed68739678da02890e2b8f79914c
[wizard.git] / bin / wizard
1 #!/usr/bin/env python
2
3 """
4 This script does everything autoinstalls!
5
6 Specifically, it:
7 * Generates basic statistics about autoinstall versions
8 * Migrates autoinstalls to the new Git format
9 """
10
11 import os
12 import optparse
13 import sys
14
15 # Add lib to path
16 sys.path.insert(0,os.path.abspath(os.path.join(__file__,'../../lib')))
17 import wizard.command
18
19 def main():
20     usage = """usage: %prog [-d|--version-dir] COMMAND [ARGS]
21
22 Wizard is a Git-based autoinstall management system for scripts.
23
24 Its commands are:
25     migrate     Migrate autoinstalls from old format to Git-based format
26     stat        Generate statistics about autoinstalls
27
28 See '%prog help COMMAND' for more information on a specific command."""
29
30     parser = optparse.OptionParser(usage)
31     parser.add_option("-d", "--version-dir", dest="version_dir",
32             default="/afs/athena.mit.edu/contrib/scripts/sec-tools/store/versions",
33             help="Location of parallel-find output")
34     # Find the end of the "global" options
35     i = 1
36     try:
37         while not sys.argv[i] or sys.argv[i][0] == '-':
38             if sys.argv[i] == "-h" or sys.argv[i] == "--help":
39                 parser.print_help()
40                 raise SystemExit(-1)
41             i += 1
42     except IndexError:
43         parser.print_help()
44         raise SystemExit(-1)
45     options, args = parser.parse_args(sys.argv[1:i+1])
46     rest_argv = sys.argv[i+1:]
47     command = args[0] # shouldn't fail
48     if command == "help":
49         try:
50             getattr(wizard.command, rest_argv[0])(['-h'], options)
51         except AttributeError:
52             parser.error("invalid action")
53         except IndexError:
54             parser.print_help()
55             raise SystemExit(-1)
56     # Dispatch commands
57     try:
58         getattr(wizard.command, command).main(rest_argv, options)
59     except AttributeError:
60         parser.error("invalid action")
61
62 if __name__ == "__main__":
63     main()
64