]> scripts.mit.edu Git - wizard.git/blob - wizard/command/list.py
Rewrite parametrize to use new parametrizeWithVars
[wizard.git] / wizard / command / list.py
1 import logging
2 import os.path
3
4 from wizard import command, deploy
5
6 def main(argv, baton):
7     options, show = parse_args(argv, baton)
8     errors = 0
9     for d in deploy.parse_install_lines(show, options.versions_path, True, user=options.user):
10         if isinstance(d, Exception):
11             errors += 1
12             continue
13         if options.exists and not os.path.exists(os.path.join(d.location, options.exists)):
14             continue
15         if options.url:
16             print d.url.geturl()
17         else:
18             print d.location
19     if errors:
20         logging.warning("%d errors, see 'wizard errors --verbose' for details" % errors)
21
22 def parse_args(argv, baton):
23     usage = """usage: %prog list [ARGS] [APP[-VERSION]]
24
25 Lists the locations of all autoinstalls, optionally
26 filtered on parameters such as application name and version.
27
28 Examples:
29     %prog list
30         List all autoinstalls
31     %prog list --exists php.ini
32         List all autoinstalls with php.ini
33     %prog list mediawiki
34         List only MediaWiki autoinstalls
35     %prog list mediawiki-1.11.0
36         List only Mediawiki 1.11.0 autoinstalls"""
37     parser = command.WizardOptionParser(usage)
38     parser.add_option("-e", "--exists", dest="exists",
39             help="only print deployment if FILE exists", metavar="FILE")
40     parser.add_option("--url", dest="url", action="store_true",
41             default=False, help="prints URLs of deployment instead of path")
42     baton.push(parser, "versions_path")
43     baton.push(parser, "user")
44     options, args = parser.parse_all(argv)
45     if len(args) > 1:
46         parser.error("too many arguments")
47     return options, args
48