parent
f734e2f172
commit
748717ff97
@ -0,0 +1,29 @@
|
|||||||
|
import subprocess
|
||||||
|
|
||||||
|
from ..color import colored
|
||||||
|
from .. import repo
|
||||||
|
|
||||||
|
|
||||||
|
def parser(subparsers, config):
|
||||||
|
parser = subparsers.add_parser('edit',
|
||||||
|
help=colored('open the paper bibliographic file in an editor',
|
||||||
|
'normal'))
|
||||||
|
parser.add_argument('reference',
|
||||||
|
help=colored('reference to the paper (citekey or number)',
|
||||||
|
'normal'))
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
def command(config, reference):
|
||||||
|
rp = repo.Repository.from_directory()
|
||||||
|
key = rp.citekey_from_ref(reference, fatal=True)
|
||||||
|
filepath = rp.path_to_paper_file(key, 'bib')
|
||||||
|
subprocess.call([config.get('papers', 'edit-cmd'),
|
||||||
|
filepath])
|
||||||
|
# TODO use editor_input from files.py instead of directly editing the file.
|
||||||
|
# Then chack that output file is correctly formmatted and that citekey has
|
||||||
|
# not changed or is still a valid citekey.
|
||||||
|
print('{} editing {}.'.format(
|
||||||
|
colored('Done', 'ok'),
|
||||||
|
colored(filepath, 'filepath')
|
||||||
|
))
|
Loading…
Reference in new issue