pubs/papers/commands/remove_cmd.py
Olivier Mangin 105ae292b9 Support for many references and refactor.
- Moves shared command code to helpers module.
- Implements reference(s) argument for commands:
  + a helper to add single or multi-reference argument to parser,
  + two functions to transform this argument into a list of citekeys.
2013-06-19 16:35:41 +02:00

22 lines
719 B
Python

from .. import repo
from .. import color
from .helpers import add_references_argument, parse_references
def parser(subparsers, config):
parser = subparsers.add_parser('remove', help='removes a paper')
add_references_argument(parser)
return parser
def command(config, ui, references):
rp = repo.Repository.from_directory(config)
citekeys = parse_references(ui, rp, references)
are_you_sure = ("Are you sure you want to delete paper(s) [%s]"
" (this will also delete associated documents)?"
% ', '.join([color.dye(c, color.citekey) for c in citekeys]))
sure = ui.input_yn(question=are_you_sure, default='n')
if sure:
for c in citekeys:
rp.remove(c)