summaryrefslogtreecommitdiff
path: root/morph
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-03-22 17:36:12 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-03-22 17:36:12 +0000
commit16037737eb6bbea91b4cc21e3895efda1f35f3ff (patch)
tree4137c7c078ea14b43ed3ccc525fdcef0184a5aa0 /morph
parent3f4031d1c0237636359e14304484fb569fcecc43 (diff)
downloadmorph-16037737eb6bbea91b4cc21e3895efda1f35f3ff.tar.gz
Implement "morph init" and fix tests accordingly
Diffstat (limited to 'morph')
-rwxr-xr-xmorph18
1 files changed, 18 insertions, 0 deletions
diff --git a/morph b/morph
index d981bbb6..5b1bed7b 100755
--- a/morph
+++ b/morph
@@ -358,6 +358,24 @@ class Morph(cliapp.Application):
def cmd_init(self, args):
'''Initialize a mine.'''
+
+ if not args:
+ args = ['.']
+ elif len(args) > 1:
+ raise cliapp.AppException('init must get at most one argument')
+
+ dirname = args[0]
+
+ if os.path.exists(dirname):
+ if os.listdir(dirname) != []:
+ raise cliapp.AppException('can only initialize empty '
+ 'directory: %s' % dirname)
+ else:
+ raise cliapp.AppException('can only initialize an existing '
+ 'empty directory: %s' % dirname)
+
+ os.mkdir(os.path.join(dirname, '.morph'))
+ os.mkdir(os.path.join(dirname, '.morph', 'cache'))
def msg(self, msg):
'''Show a message to the user about what is going on.'''