diff --git a/pubs/commands/note_cmd.py b/pubs/commands/note_cmd.py index 367e799..72ad5c7 100644 --- a/pubs/commands/note_cmd.py +++ b/pubs/commands/note_cmd.py @@ -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()