Added '-a' (--append) arg to append a line of text to the notes file.

https://github.com/pubs/pubs/issues/200
main
dvklopfenstein 6 years ago
parent 5551e8c04b
commit 634a500438

@ -10,6 +10,7 @@ def parser(subparsers, conf):
help='edit the note attached to a paper')
parser.add_argument('citekey', help='citekey of the paper',
).completer = CiteKeyCompletion(conf)
parser.add_argument('-a', '--append', help='append a line of text to the notes file', default=None)
return parser
@ -18,7 +19,12 @@ def command(conf, args):
ui = get_ui()
rp = repo.Repository(conf)
citekey = resolve_citekey(rp, args.citekey, ui=ui, exit_on_fail=True)
append = args.append
notepath = rp.databroker.real_notepath(citekey, rp.conf['main']['note_extension'])
ui.edit_file(notepath, temporary=False)
if append is None:
ui.edit_file(notepath, temporary=False)
else:
with open(notepath, 'a') as fd:
fd.write(append)
NoteEvent(citekey).send()
rp.close()

Loading…
Cancel
Save