diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-11 19:03:25 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-11 19:03:25 +0100 |
commit | 1faa54518a0f58357570cfba043aefb63d5daa60 (patch) | |
tree | a2f980c7b314d602463106424b11563832396df3 | |
parent | fef72b43b92d8f8eb3d27fdaa0799227fa61507b (diff) | |
download | jt-1faa54518a0f58357570cfba043aefb63d5daa60.tar.gz |
Add cmd_remove
-rwxr-xr-x | journal-note | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/journal-note b/journal-note index b46fdbf..0852eb7 100755 --- a/journal-note +++ b/journal-note @@ -151,11 +151,18 @@ class JournalNote(cliapp.Application): for filename in args[1:]: shutil.copy(filename, dirname) - # def cmd_remove(self, args, opts): - # if not args: - # raise AppException('Usage: journal-note remove ID') - # pathname = self.draftname(opts, args[0]) - # os.remove(pathname) + def cmd_remove(self, args): + '''Remove a draft.''' + + if not args: + raise cliapp.AppException('Usage: journal-note remove ID') + filename = self.draft_name(args[0]) + os.remove(filename) + + dirname, ext = os.path.splitext(filename) + assert ext == '.mdwn' + if os.path.exists(dirname): + shutil.rmtree(dirname) def cmd_finish(self, args): '''Publish a draft journal entry.''' |