summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-11-22 19:46:58 +0200
committerLars Wirzenius <liw@liw.fi>2014-11-22 19:46:58 +0200
commit275f7ebd71e6f0335772496e5904c4e1b52a4e65 (patch)
treea439d32bebe62187995fc0fbd7f37fa585f5defd
parenta9ae0264de61e057972d0c08436e50a0e016e379 (diff)
downloadjt-275f7ebd71e6f0335772496e5904c4e1b52a4e65.tar.gz
Re-order cmd_ methods to be together
-rwxr-xr-xjt52
1 files changed, 26 insertions, 26 deletions
diff --git a/jt b/jt
index d41bb55..02a9bb8 100755
--- a/jt
+++ b/jt
@@ -309,14 +309,6 @@ class JournalTool(cliapp.Application):
'''Create a new journal entry draft.'''
NewCommand(self).run(args)
- def drafts_dir(self):
- return os.path.join(self.settings['source'], 'drafts')
-
- def edit_file(self, pathname):
- safe_pathname = cliapp.shell_quote(pathname)
- cmdline = ['sh', '-c', self.settings['editor'] % pathname]
- self.runcmd(cmdline, stdin=None, stdout=None, stderr=None)
-
def cmd_list(self, args):
'''List journal entry drafts.'''
ListCommand(self).run(args)
@@ -325,24 +317,6 @@ class JournalTool(cliapp.Application):
'''Edit a draft journal entry.'''
EditCommand(self).run(args)
- def choose_draft(self, drafts_dir, args):
- if len(args) == 0:
- drafts = list(drafts_dir.get_drafts())
- if len(drafts) == 1:
- draft_id, filename = drafts[0]
- return draft_id, filename
- elif len(drafts) == 0:
- raise cliapp.AppException('No drafts to choose from')
- else:
- raise cliapp.AppException('Cannot choose entry draft automatically')
- elif len(args) == 1:
- pathname = drafts_dir.get_draft_pathname(args[0])
- if not os.path.exists(pathname):
- raise cliapp.AppException('draft %s does not exist' % args[0])
- return args[0], pathname
- elif len(args) > 1:
- raise cliapp.AppException('Must give at most one draft number')
-
def cmd_attach(self, args):
'''Attach files to a journal entry draft.'''
AttachCommand(self).run(args)
@@ -364,5 +338,31 @@ class JournalTool(cliapp.Application):
NewPersonCommand(self).run(args)
+ def drafts_dir(self):
+ return os.path.join(self.settings['source'], 'drafts')
+
+ def edit_file(self, pathname):
+ safe_pathname = cliapp.shell_quote(pathname)
+ cmdline = ['sh', '-c', self.settings['editor'] % pathname]
+ self.runcmd(cmdline, stdin=None, stdout=None, stderr=None)
+
+ def choose_draft(self, drafts_dir, args):
+ if len(args) == 0:
+ drafts = list(drafts_dir.get_drafts())
+ if len(drafts) == 1:
+ draft_id, filename = drafts[0]
+ return draft_id, filename
+ elif len(drafts) == 0:
+ raise cliapp.AppException('No drafts to choose from')
+ else:
+ raise cliapp.AppException('Cannot choose entry draft automatically')
+ elif len(args) == 1:
+ pathname = drafts_dir.get_draft_pathname(args[0])
+ if not os.path.exists(pathname):
+ raise cliapp.AppException('draft %s does not exist' % args[0])
+ return args[0], pathname
+ elif len(args) > 1:
+ raise cliapp.AppException('Must give at most one draft number')
+
JournalTool(version=__version__).run()