Merge pull request #1002 from pdvyas/fix-new-app

Fix new-app
This commit is contained in:
Pratik Vyas 2015-02-10 14:44:19 +05:30
commit 21201ce00a
2 changed files with 12 additions and 10 deletions

View file

@ -29,7 +29,6 @@ def main():
sites_path = parsed_args.get("sites_path")
if not parsed_args.get("make_app"):
if parsed_args.get("site")=="all":
for site in get_sites(parsed_args["sites_path"]):
print "\nRunning", fn, "for", site
@ -129,7 +128,7 @@ def setup_parser():
return parser.parse_args()
def setup_install(parser):
parser.add_argument("--make_app", metavar="DEST", nargs=1,
parser.add_argument("--make_app", metavar=("DESTINATION", "APP-NAME"), nargs=2,
help="Make a new application with boilerplate")
parser.add_argument("--install", metavar="DB-NAME", nargs=1,
help="Install a new db")
@ -293,9 +292,9 @@ def setup_translation(parser):
# methods
@cmd
def make_app(destination):
def make_app(destination, app_name):
from frappe.utils.boilerplate import make_boilerplate
make_boilerplate(destination)
make_boilerplate(destination, app_name)
@cmd
def use(sites_path):

View file

@ -6,25 +6,29 @@ from __future__ import unicode_literals
import frappe, os
from frappe.utils import touch_file
def make_boilerplate(dest):
def make_boilerplate(dest, app_name):
if not os.path.exists(dest):
print "Destination directory does not exist"
return
hooks = frappe._dict()
for key in ("App Name", "App Title", "App Description", "App Publisher",
"App Icon", "App Color", "App Email", "App URL", "App License"):
hook_key = key.lower().replace(" ", "_")
hooks.app_name = app_name
app_title = hooks.app_name.replace("_", " ").title()
for key in ("App Title (defaut: {0})".format(app_title), "App Description", "App Publisher",
"App Icon (e.g. 'octicon octicon-zap')", "App Color", "App Email", "App License"):
hook_key = key.split(" (")[0].lower().replace(" ", "_")
hook_val = None
while not hook_val:
hook_val = raw_input(key + ": ")
if hook_key=="app_name" and hook_val.lower().replace(" ", "_") != hook_val:
print "App Name must be all lowercase and without spaces"
hook_val = ""
elif hook_key=="app_title" and not hook_val:
hook_val = app_title
hooks[hook_key] = hook_val
frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, frappe.scrub(hooks.app_title)),
frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, hooks.app_title),
with_init=True)
frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "templates"), with_init=True)
frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "templates",
@ -94,7 +98,6 @@ app_description = "{app_description}"
app_icon = "{app_icon}"
app_color = "{app_color}"
app_email = "{app_email}"
app_url = "{app_url}"
app_version = "0.0.1"
# Includes in <head>