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