diff options
-rwxr-xr-x | jt | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -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.''' |