# get configuration
schema = application.install_schema
+ schema.commit(dir)
options = None
opthandler = installopt.Controller(dir, schema)
ihandler = interactive.Controller(dir, schema, input)
parser = command.WizardOptionParser("""usage: %%prog install %s DIR [ -- SETUPARGS ]
Autoinstalls the application %s in the directory DIR.""" % (appname, appname))
+ configure_parser(parser, baton)
opthandler.push(parser)
if old_options.help:
parser.print_help()
git.commit_configure()
input.infobox("Congratulations, your new install is now accessible at http://%s%s" % (options.web_host, options.web_path))
+def configure_parser(parser, baton):
+ parser.add_option("--prompt", dest="prompt", action="store_true",
+ default=False, help="Force to use non-ncurses interactive interface")
+ parser.add_option("--non-interactive", dest="non_interactive", action="store_true",
+ default=False, help="Force program to be non-interactive and use SETUPARGS. Use --help with APP to find argument names.")
+ baton.push(parser, "srv_path")
+
def parse_args(argv, baton):
usage = """usage: %prog install APP DIR [ -- SETUPARGS ]
Autoinstalls the application APP in the directory DIR.
This command will interactively ask for information to
-complete the autoinstall."""
+complete the autoinstall.
+
+You can also use --help with APP and DIR to find out what
+are required SETUPARGS if you want to run this non-interactively
+(the distribution of required and optional arguments may change
+depending on what directory you are installing to.)"""
parser = command.WizardOptionParser(usage, store_help=True)
- parser.add_option("--prompt", dest="prompt", action="store_true",
- default=False, help="Force to use non-ncurses interactive interface")
- parser.add_option("--non-interactive", dest="non_interactive", action="store_true",
- default=False, help="Force program to be non-interactive and use SETUPARGS. Use --help with APP to find argument names.")
- baton.push(parser, "srv_path")
+ configure_parser(parser, baton)
options, args = parser.parse_all(argv)
if options.help:
if len(args) == 0:
+import optparse
+
def attr_to_option(variable):
"""
Converts Python attribute names to command line options.
self.schema = schema
def push(self, parser):
"""Pushes arg schema to :class:`optparse.OptionParser`."""
+ required = optparse.OptionGroup(parser, "Required Arguments (SETUPARGS)")
+ optional = optparse.OptionGroup(parser, "Optional Arguments (SETUPARGS)")
for arg in self.schema.args.values():
- parser.add_option(attr_to_option(arg.name), dest=arg.name, metavar=arg.type,
+ group = arg.name in self.schema.provides and optional or required
+ group.add_option(attr_to_option(arg.name), dest=arg.name, metavar=arg.type,
default=None, help=arg.help)
+ parser.add_option_group(required)
+ parser.add_option_group(optional)
def handle(self, options):
"""
Performs post-processing for the options, including throwing
errors if not all arguments are specified.
"""
- self.schema.commit(self.dir)
self.schema.load(options)