diff options
Diffstat (limited to 'jt')
-rwxr-xr-x | jt | 35 |
1 files changed, 24 insertions, 11 deletions
@@ -31,16 +31,6 @@ import traceback __version__ = '0.4' -template = '''\ -[[!meta title="%(title)s"]] -[[!tag ]] -[[!meta date="%(date)s"]] - -%(topiclink)s - -''' - - class DraftsDirectory(object): def __init__(self, dirname): @@ -112,6 +102,15 @@ class Command(object): class NewCommand(Command): + _default_new_note_template = '''\ +[[!meta title="%(title)s"]] +[[!tag ]] +[[!meta date="%(date)s"]] + +%(topiclink)s + +''' + def run(self, args): if not args: raise cliapp.AppException('Usage: journal-note new TITLE') @@ -129,7 +128,8 @@ class NewCommand(Command): drafts_dir = DraftsDirectory(self._app.drafts_dir()) drafts_dir.create_if_missing() - draft_id = drafts_dir.create_draft(template % values) + draft_id = drafts_dir.create_draft( + self._get_new_note_template() % values) self._app.edit_file(drafts_dir.get_draft_pathname(draft_id)) def _topic_page_exists(self, topic): @@ -142,6 +142,14 @@ class NewCommand(Command): else: return '' + def _get_new_note_template(self): + filename = self._app.settings['new-note-template'] + if filename: + with open(filename) as f: + return f.read() + else: + return self._default_new_note_template + class ListCommand(Command): @@ -350,6 +358,11 @@ class JournalTool(cliapp.Application): metavar='TOPIC') self.settings.string( + ['new-note-template'], + 'use FILE as the template for new journal notes', + metavar='FILE') + + self.settings.string( ['pretend-time'], 'pretend that the time is NOW (form: YYYY-MM-DD HH:MM:DD form)', metavar='NOW') |