diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-11 16:40:04 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-11 16:40:04 +0100 |
commit | e64f9c789faff4d71a6a98a501e0b36e49c0fdb9 (patch) | |
tree | 605bd08837f4c146e581694ffb8c5b4848a0783b | |
parent | bb1e33f6802b0ea0cf9106ba3c57c49515a1e9d1 (diff) | |
download | jt-e64f9c789faff4d71a6a98a501e0b36e49c0fdb9.tar.gz |
Implement cmd_new
-rwxr-xr-x | journal-note | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/journal-note b/journal-note index 26b6d9d..006bd6e 100755 --- a/journal-note +++ b/journal-note @@ -37,12 +37,27 @@ template = '''\ class JournalNote(cliapp.Application): - def cmd_new_entry(self, args): + def add_settings(self): + self.settings.string( + ['source'], + 'use journal source tree in DIR', + metavar='DIR') + + self.settings.choice( + ['layout'], + ['liw', 'ct'], + 'use journal layout (one of liw, ct)', + metavar='LAYOUT') + + def cmd_new(self, args): if not args: raise cliapp.AppException('Usage: journal-note new TITLE') + self.settings.require('source') + self.settings.require('layout') + for i in range(1000): - name = self.draftname(opts, i) + name = self.draft_name(i) if not os.path.exists(name): break else: @@ -57,6 +72,13 @@ class JournalNote(cliapp.Application): f.close() self.edit_file(name) + def draft_name(self, draft_id): + return os.path.join( + self.settings['source'], 'drafts', '%s.mdwn' % draft_id) + + def edit_file(self, pathname): + subprocess.check_call(['echo', 'sensible-editor', pathname]) + # def cmd_list(self, args): # drafts = self.drafts() # for draft_id, name in self.find_drafts(): @@ -73,12 +95,6 @@ class JournalNote(cliapp.Application): # f.close() # print draft_id, title - # def draftname(self, opts, draft_id): - # return os.path.join(opts.base, 'drafts', '%s.mdwn' % draft_id) - - # def edit_file(self, pathname): - # subprocess.check_call(['gedit', '--new-window', pathname]) - # def find_drafts(self, opts): # drafts = self.drafts(opts) # for name in os.listdir(drafts): |