summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-10-11 19:03:25 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-10-11 19:03:25 +0100
commit1faa54518a0f58357570cfba043aefb63d5daa60 (patch)
treea2f980c7b314d602463106424b11563832396df3
parentfef72b43b92d8f8eb3d27fdaa0799227fa61507b (diff)
downloadjt-1faa54518a0f58357570cfba043aefb63d5daa60.tar.gz
Add cmd_remove
-rwxr-xr-xjournal-note17
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.'''