diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-03-22 17:36:12 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-03-22 17:36:12 +0000 |
commit | 16037737eb6bbea91b4cc21e3895efda1f35f3ff (patch) | |
tree | 4137c7c078ea14b43ed3ccc525fdcef0184a5aa0 /morph | |
parent | 3f4031d1c0237636359e14304484fb569fcecc43 (diff) | |
download | morph-16037737eb6bbea91b4cc21e3895efda1f35f3ff.tar.gz |
Implement "morph init" and fix tests accordingly
Diffstat (limited to 'morph')
-rwxr-xr-x | morph | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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.''' |