summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-11-22 18:19:24 +0200
committerLars Wirzenius <liw@liw.fi>2014-11-22 18:19:24 +0200
commit32774872566e0c29aefec26d8fbc41242afebbef (patch)
treea98158eacc79e677453a2c85315c9819b24b5e3f
parent8208026cf7eb3e30217ebd76424378f1afef4cdd (diff)
downloadjt-32774872566e0c29aefec26d8fbc41242afebbef.tar.gz
Move command remove to a separate class
-rwxr-xr-xjt26
1 files changed, 16 insertions, 10 deletions
diff --git a/jt b/jt
index 9c54f14..ad02c62 100755
--- a/jt
+++ b/jt
@@ -108,6 +108,21 @@ class AttachCommand(Command):
shutil.copy(filename, dirname)
+class RemoveCommand(Command):
+
+ def run(self, args):
+ if not args:
+ raise cliapp.AppException('Usage: journal-note remove ID')
+
+ filename = self._app.draft_name(args[0])
+ os.remove(filename)
+
+ dirname, ext = os.path.splitext(filename)
+ assert ext == '.mdwn'
+ if os.path.exists(dirname):
+ shutil.rmtree(dirname)
+
+
class JournalTool(cliapp.Application):
cmd_synopsis = {
@@ -216,16 +231,7 @@ class JournalTool(cliapp.Application):
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)
+ RemoveCommand(self).run(args)
def cmd_finish(self, args):
'''Publish a draft journal entry.'''