#! python
#
# currently assumes that we are creating apps in a virtualenv folder, which contains the evoke distribution

import sys
from shutil import copytree,rmtree #,move
from os import walk

help="""
clone an evo application in a folder named appname (this must not already exist)

( currently assumes that we are creating the app in a virtualenv folder, which contains the evoke distribution )

usage: create_app appname 
options:  <none>
(IHM Nov 2007 onwards)
"""
if len(sys.argv)>1:
 app=sys.argv[1] #arguments

 #copy the files
 print('creating "%s"...' % app) 
 # code first
 dst=app
 copytree("app",dst,symlinks=True)
 # flat file data (template)
 dst='site/%s' % app
 copytree("site/evoke/app_template",dst,symlinks=True)

# #rename local css and js
# move("%s/htdocs/site/app.css" % dst,"%s/htdocs/site/%s.css" %(dst,app)) 
# move("%s/htdocs/site/app.js" % dst,"%s/htdocs/site/%s.js" %(dst,app)) 

 print("""
"%s" created.

Now:
     1) import to repository, if desired
THEN 2) change directory to %s/
THEN 3) create config_site.py for the app, as required 
THEN 4) ./devstart  (or ./start) to create the database, and start the server

NOTE: Database name will default to "%s" unless overridden in config_site.py
""" % (app,app,app))

else:
  print(help)

