]> scripts.mit.edu Git - wizard.git/blob - wizard/command/database.py
Refactor change directory code to be consistent and permissive.
[wizard.git] / wizard / command / database.py
1 import os.path
2
3 from wizard import deploy, command, shell
4
5 def main(argv, baton):
6     options, args = parse_args(argv, baton)
7     dir = os.path.abspath(args[0]) if args else os.getcwd()
8     shell.drop_priviledges(dir, options.log_file)
9     deployment = deploy.ProductionCopy(dir)
10     print deployment.dsn.database
11
12 def parse_args(argv, baton):
13     usage = """usage: %prog database [DIR]
14
15 Prints the name of the database an application is using.
16 Maybe in the future this will print more information."""
17     parser = command.WizardOptionParser(usage)
18     options, args = parser.parse_all(argv)
19     if len(args) > 1:
20         parser.error("too many arguments")
21     if len(args) == 0:
22         parser.error("must specify directory")
23     return options, args