]> scripts.mit.edu Git - wizard.git/blob - bin/wizard
Fix 'wizard' to print help.
[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.dirname(os.path.dirname(os.path.abspath(__file__))))
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     upgrade         Upgrades an autoinstall to the latest version
22
23 See '%prog help COMMAND' for more information on a specific command."""
24
25     parser = optparse.OptionParser(usage)
26     parser.disable_interspersed_args()
27     parser.add_option("-s", "--versions", dest="versions",
28             default="/afs/athena.mit.edu/contrib/scripts/sec-tools/store/versions",
29             help="Location of parallel-find output directory, or a file containing a newline separated list of 'all autoinstalls' (for testing).")
30     # Find the end of the "global" options
31     options, args = parser.parse_args()
32     rest_argv = args[1:]
33     try:
34         command = args[0]
35     except IndexError:
36         parser.print_help()
37         raise SystemExit(-1)
38     if command == "help":
39         try:
40             getattr(wizard.command, rest_argv[0]).main(['-h'], options)
41         except AttributeError:
42             parser.error("invalid action")
43         except IndexError:
44             parser.print_help()
45             raise SystemExit(-1)
46     # Dispatch commands
47     try:
48         command_module = getattr(wizard.command, command)
49     except AttributeError:
50         parser.error("invalid action")
51     command_module.main(rest_argv, options)
52
53 if __name__ == "__main__":
54     main()
55