diff options
Diffstat (limited to 'jt')
-rwxr-xr-x | jt | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -105,14 +105,9 @@ class NewCommand(Command): ''' def run(self, args): - if not args: - raise cliapp.AppException('Usage: journal-note new TITLE') + self._check_args_and_settings(args) - self._app.settings.require('source') topic = self._app.settings['topic'] - if topic and not self._topic_page_exists(topic): - raise cliapp.AppException('Topic %s does not exist yet' % topic) - values = { 'title': args[0], 'date': time.strftime('%Y-%m-%d %H:%M', self._app.now_tuple), @@ -125,6 +120,15 @@ class NewCommand(Command): self._get_new_note_template() % values) self._app.edit_file(drafts_dir.get_draft_pathname(draft_id)) + def _check_args_and_settings(self, args): + if not args: + raise cliapp.AppException('Usage: journal-note new TITLE') + + self._app.settings.require('source') + topic = self._app.settings['topic'] + if topic and not self._topic_page_exists(topic): + raise cliapp.AppException('Topic %s does not exist yet' % topic) + def _topic_page_exists(self, topic): pathname = os.path.join(self._app.settings['source'], topic + '.mdwn') return os.path.exists(pathname) |