]> scripts.mit.edu Git - wizard.git/blob - wizard/command/configure.py
Implement less braindead help messages for installation.
[wizard.git] / wizard / command / configure.py
1 import logging
2 import optparse
3 import sys
4
5 from wizard import command, deploy, git
6
7 def main(argv, baton):
8
9     usage = """usage: %prog configure [ARGS]
10
11 Takes an already cloned working copy and configures the
12 application.  Options change depending on the current
13 working directory.
14
15 WARNING: This command's API may change."""
16
17     # XXX: squick squick squick
18     if argv and argv[0][0] != '-':
19         if '--help' not in argv and '-h' not in argv:
20             argv.append('--help')
21     if '--help' in argv or '-h' in argv:
22         # Do a "fake parse" in order to get out the application name
23         parser = optparse.OptionParser(usage, add_help_option=False)
24         parser.add_option("--help", "-h", action="store_true")
25         options, args = parser.parse_args(argv)
26         try:
27             application = args[0]
28         except IndexError:
29             parser.error("Use 'wizard configure --help APP' to see APP-specific options.")
30     else:
31         tag = git.describe()
32         application, _, version = tag.partition('-')
33
34     app = deploy.applications()[application]
35     handler = app.install_handler
36
37     parser = command.WizardOptionParser(usage)
38     handler.push(parser)
39     options, args = parser.parse_all(argv)
40     handler.handle(options)
41
42     app.install(options)
43