[Checkins] SVN: grokproject/trunk/ do proper cmd line argument
parsing, provide a better error message,
Philipp von Weitershausen
philikon at philikon.de
Wed Jan 10 14:32:31 EST 2007
Log message for revision 71894:
do proper cmd line argument parsing, provide a better error message,
and make username/passwd for the initial administrator user mandatory
fields.
Changed:
U grokproject/trunk/TODO.txt
U grokproject/trunk/src/grokproject/__init__.py
-=-
Modified: grokproject/trunk/TODO.txt
===================================================================
--- grokproject/trunk/TODO.txt 2007-01-10 18:29:13 UTC (rev 71893)
+++ grokproject/trunk/TODO.txt 2007-01-10 19:32:31 UTC (rev 71894)
@@ -4,6 +4,4 @@
* silence buildout output and be more informative on the other hand
-* proper arguments parsing (support --help, etc.)
-
* support svn sandbox creation
Modified: grokproject/trunk/src/grokproject/__init__.py
===================================================================
--- grokproject/trunk/src/grokproject/__init__.py 2007-01-10 18:29:13 UTC (rev 71893)
+++ grokproject/trunk/src/grokproject/__init__.py 2007-01-10 19:32:31 UTC (rev 71894)
@@ -1,5 +1,8 @@
-from paste.script import templates
-from paste.script.templates import var
+import sys
+import os.path
+import optparse
+from paste.script import templates, command
+from paste.script.templates import var, NoDefault
class GrokProject(templates.Template):
_template_dir = 'template'
@@ -7,24 +10,33 @@
required_templates = []
vars = [
- # TODO required parameters
- var('user', 'Name of an initial administrator user'),
- var('passwd', 'Password for the initial administrator user'),
+ var('user', 'Name of an initial administrator user', default=NoDefault),
+ var('passwd', 'Password for the initial administrator user',
+ default=NoDefault),
]
def main():
- import sys
- import os.path
- from paste.script import command
+ usage = "usage: %prog [options] PROJECT"
+ parser = optparse.OptionParser(usage=usage)
+ parser.add_option('--dry-run', action="store_true", dest="dry_run",
+ default=False, help="Only create project area, do not "
+ "bootstrap the buildout.")
+ options, args = parser.parse_args()
+ if len(args) != 1:
+ parser.print_usage()
+ return 1
# create sandbox using paste.script
- project = sys.argv[1] # TODO parse arguments properly
+ project = args[0]
commands = command.get_commands()
- command = commands['create'].load()
- runner = command('create')
+ cmd = commands['create'].load()
+ runner = cmd('create')
exit_code = runner.run(['-t', 'grokproject', project])
# TODO exit_code
+ if options.dry_run:
+ return
+
# bootstrap the buildout
os.chdir(project)
bootstrap_py = os.path.join(os.getcwd(), 'bootstrap', 'bootstrap.py')
More information about the Checkins
mailing list