diff options
Diffstat (limited to 'yaksh/scripts')
-rw-r--r-- | yaksh/scripts/cli.py (renamed from yaksh/scripts/yaksh.py) | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/yaksh/scripts/yaksh.py b/yaksh/scripts/cli.py index 4360d1b..79523f9 100644 --- a/yaksh/scripts/yaksh.py +++ b/yaksh/scripts/cli.py @@ -20,13 +20,15 @@ TEMPLATE_DIR = path.join(PARENT_DIR, 'demo_templates') def main(): #Parse command-line to obtain the arguments and/or options # create top-level parser object - parser = argparse.ArgumentParser(prog="vimarsh") + parser = argparse.ArgumentParser(prog="yaksh") subparser = parser.add_subparsers(dest="subcommand") # create parser for the "create_demo" subcommand create_demo_parser = subparser.add_parser("create_demo", help="Create a new demo Django project") create_demo_parser.add_argument("project_name", type=str, + default="yaksh_demo", + nargs="?", help="name of demo Django project") create_demo_parser.add_argument("-p", "--path", type=str, help="path of demo Django project") @@ -37,7 +39,7 @@ def main(): # create parser for the "run_code_server" subcommand code_server_parser = subparser.add_parser("run_code_server", - help="Initialise Vimarsh code server") + help="Initialise yaksh code server") code_server_parser.add_argument("-P", "--ports", type=int, nargs='+', help="code server ports") @@ -65,13 +67,13 @@ def main(): else: run_server() -def create_demo(project_name='vimarsh_demo', project_dir=CUR_DIR): +def create_demo(project_name='yaksh_demo', project_dir=CUR_DIR): try: management.call_command('startproject', project_name, project_dir) print("Demo Django project '{0}' created at '{1}'".format(project_name, project_dir)) except Exception, e: - print("Error: {0}\nExiting Vimarsh Installer".format(e)) + print("Error: {0}\nExiting yaksh Installer".format(e)) if project_dir is None: top_dir = path.join(os.getcwd(), project_name) @@ -80,6 +82,7 @@ def create_demo(project_name='vimarsh_demo', project_dir=CUR_DIR): project_path = path.join(top_dir, project_name) fixture_dir = path.join(PARENT_DIR, 'fixtures') + fixture_path = path.join(fixture_dir, 'demo_fixtures.json') # Store project details _set_project_details(project_name, top_dir) @@ -95,12 +98,15 @@ def create_demo(project_name='vimarsh_demo', project_dir=CUR_DIR): command = ("python ../manage.py syncdb " "--noinput --settings={0}.demo_settings").format(project_name) + loaddata_command = ("python ../manage.py loaddata " + "--settings={0}.demo_settings {1}").format(project_name, fixture_path) + # Create demo_settings file _render_demo_files(settings_template_path, settings_target_path, settings_context) # Create demo_urls file _render_demo_files(urls_template_path, urls_target_path) # Run syncdb - subprocess.call(command, shell=True) + subprocess.call("{0}; {1}".format(command, loaddata_command), shell=True) def run_demo(project_name, top_dir): with _chdir(top_dir): @@ -114,7 +120,7 @@ def run_server(): from yaksh import code_server code_server.main() except Exception as e: - print("Error: {0}\nExiting Vimarsh code server".format(e)) + print("Error: {0}\nExiting yaksh code server".format(e)) def _set_project_details(project_name, top_dir): file_path = path.join(SCRIPT_DIR, 'project_detail.py') |