6 from wizard import app, command, git, shell, util
7 from wizard.install import installopt
10 old_options, args = parse_args(argv, baton)
11 # XXX: do something smart if -scripts is not at the end
14 if os.path.exists(dir):
15 raise DirectoryExistsError
16 appname, _, version = appstr.partition('-')
17 application = app.applications()[appname]
20 schema = application.install_schema
21 handler = installopt.Controller(schema)
22 parser = command.WizardOptionParser()
24 options, _ = parser.parse_all(args[2:] + command.make_base_args(old_options)) # accumulate
25 handler.handle(options)
28 sys.stderr.write("Copying files...\n")
29 sh.call("git", "clone", "-q", "--shared", application.repository(old_options.srv_path), dir)
30 with util.ChangeDirectory(dir):
32 sh.call("git", "reset", "-q", "--hard", appstr)
33 sys.stderr.write("Installing...\n")
34 application.install(distutils.version.LooseVersion(version), options)
35 git.commit_configure()
37 def parse_args(argv, baton):
38 usage = """usage: %prog install [APP [DIR -- [SETUPARGS]]]
40 Autoinstalls the application APP in the directory
41 DIR. SETUPARGS are arguments that are passed to
42 'wizard configure', see 'wizard configure APP --help'
43 for possible arguments.
45 WARNING: This command's API may change."""
46 parser = command.WizardOptionParser(usage)
47 baton.push(parser, "srv_path")
48 options, args = parser.parse_all(argv)
49 # XXX: in the future, not specifying stuff is supported, since
50 # we'll prompt for it interactively
52 parser.error("must specify application and directory")
54 parser.error("must specify directory")
57 class DirectoryExistsError(wizard.Error):
59 return "Directory already exists"