diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-11 19:02:05 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-11 19:02:05 +0100 |
commit | fef72b43b92d8f8eb3d27fdaa0799227fa61507b (patch) | |
tree | ebcc37e995d1e5d4277b352b41ebc30d9666af0f | |
parent | 18660081f6a6a3b8118ef772b36da54bbe0344e4 (diff) | |
download | jt-fef72b43b92d8f8eb3d27fdaa0799227fa61507b.tar.gz |
Add cmd_attach
-rwxr-xr-x | journal-note | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/journal-note b/journal-note index eaea036..b46fdbf 100755 --- a/journal-note +++ b/journal-note @@ -135,17 +135,21 @@ class JournalNote(cliapp.Application): elif len(args) > 1: raise cliapp.AppException('Must give only one draft number') - # def cmd_attach(self, args, opts): - # if len(args) < 2: - # raise AppException('Usage: journal-note attach ID file...') - # pathname = self.draftname(opts, args[0]) - # if not os.path.exists(pathname): - # raise AppException('draft %s does not exist' % args[0]) - # dirname, ext = os.path.splitext(pathname) - # if not os.path.exists(dirname): - # os.mkdir(dirname) - # for filename in args[1:]: - # shutil.copy(filename, dirname) + def cmd_attach(self, args): + '''Attach files to a journal entry draft.''' + + if len(args) < 2: + raise cliapp.AppException('Usage: journal-note attach ID file...') + + filename = self.draft_name(args[0]) + + dirname, ext = os.path.splitext(filename) + assert ext == '.mdwn' + + if not os.path.exists(dirname): + os.mkdir(dirname) + for filename in args[1:]: + shutil.copy(filename, dirname) # def cmd_remove(self, args, opts): # if not args: |