import logging import optparse import sys from wizard import command, deploy, git def main(argv, baton): usage = """usage: %prog configure [ARGS] Takes an already cloned working copy and configures the application. Options change depending on the current working directory. WARNING: This command's API may change.""" # XXX: squick squick squick if argv and argv[0][0] != '-': if '--help' not in argv and '-h' not in argv: argv.append('--help') if '--help' in argv or '-h' in argv: # Do a "fake parse" in order to get out the application name parser = optparse.OptionParser(usage, add_help_option=False) parser.add_option("--help", "-h", action="store_true") options, args = parser.parse_args(argv) try: application = args[0] except IndexError: parser.error("Use 'wizard configure --help APP' to see APP-specific options.") else: tag = git.describe() application, _, version = tag.partition('-') app = deploy.applications()[application] handler = app.install_handler parser = command.WizardOptionParser(usage) handler.push(parser) options, args = parser.parse_all(argv) handler.handle(options) app.install(options)