]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/install.py
Fix absolute path from environment bug and debug-all-the-time bug.
[wizard.git] / wizard / command / install.py
index a331e2e42c8c1391cc46d9cf2c185448b28bc853..746463169e40ded3deb0d8ac2bf0b50a53861d3d 100644 (file)
@@ -8,25 +8,27 @@ import wizard
 from wizard import command, deploy, shell, util
 
 def main(argv, baton):
-    options, args = parse_args(argv)
+    options, args = parse_args(argv, baton)
     # XXX: do something smart if -scripts is not at the end
-    dir = args[0]
+    app = args[0]
+    dir = args[1]
     if os.path.exists(dir):
         raise DirectoryExistsError
-    appname, _, version = options.app.partition('-')
-    app = deploy.applications()[appname]
+    appname, _, version = app.partition('-')
+    application = deploy.applications()[appname]
     sh = shell.Shell()
-    sh.call("git", "clone", "--shared", app.repository, dir)
+    sh.call("git", "clone", "--shared", application.repository(options.srv_path), dir)
     with util.ChangeDirectory(dir):
         if version:
-            sh.call("git", "checkout", options.app)
+            sh.call("git", "checkout", app)
         # this command's stdin should be hooked up to ours
         try:
-            sh.call("wizard", "configure", *args[1:], interactive=True)
+            configure_args = args[2:] + command.makeBaseArgs(options)
+            sh.call("wizard", "configure", *configure_args, interactive=True)
         except shell.PythonCallError:
             sys.exit(1)
 
-def parse_args(argv):
+def parse_args(argv, baton):
     usage = """usage: %prog install [APP [DIR -- [SETUPARGS]]]
 
 Autoinstalls the application APP in the directory
@@ -36,13 +38,14 @@ for possible arguments.
 
 WARNING: This command's API may change."""
     parser = command.WizardOptionParser(usage)
-    parser.add_option("--app", dest="app",
-            help="Application to install, optionally specifying a version as APP-VERSION")
+    baton.push(parser, "srv_path")
     options, args = parser.parse_all(argv)
+    # XXX: in the future, not specifying stuff is supported, since
+    # we'll prompt for it interactively
     if not args:
-        # XXX: in the future, not specifying stuff is supported, since
-        # we'll prompt for it interactively
-        parser.error("must specify application")
+        parser.error("must specify application and directory")
+    elif len(args) == 1:
+        parser.error("must specify directory")
     return options, args
 
 class DirectoryExistsError(wizard.Error):