diff --git a/setup.py b/setup.py index 1812dc8db9..8786403626 100644 --- a/setup.py +++ b/setup.py @@ -76,7 +76,7 @@ setup( install_requires=install_requires, entry_points=""" [console_scripts] - wagtail-project=wagtail.bin.wagtail_project:create_project + wagtail=wagtail.bin.wagtail:main """, zip_safe=False, ) diff --git a/wagtail/bin/wagtail_project.py b/wagtail/bin/wagtail.py similarity index 75% rename from wagtail/bin/wagtail_project.py rename to wagtail/bin/wagtail.py index 8cf261a326..6d7e71c7c3 100644 --- a/wagtail/bin/wagtail_project.py +++ b/wagtail/bin/wagtail.py @@ -7,15 +7,14 @@ import sys from optparse import OptionParser -def create_project(): - # Collect and analyse the name given for the wagtail project - parser = OptionParser(usage="Usage: %prog project_name") - (options, args) = parser.parse_args() - - if len(args) != 1: +def create_project(parser, options, args): + # Validate args + if len(args) < 2: parser.error("Please specify a name for your wagtail installation") + elif len(args) > 2: + parser.error("Too many arguments") - project_name = args[0] + project_name = args[1] # Make sure given name is not already in use by another python package/module. try: @@ -53,5 +52,21 @@ def create_project(): print "Success! %(project_name)s is created" % {'project_name': project_name} +COMMANDS = { + 'start': create_project, +} + +def main(): + # Parse options + parser = OptionParser(usage="Usage: %prog start project_name") + (options, args) = parser.parse_args() + + # Find command + command = args[0] + if command in COMMANDS: + COMMANDS[command](parser, options, args) + else: + parser.error("Unrecognised command: " + command) + if __name__ == "__main__": - create_project() + main()