|
|
@ -1,13 +1,13 @@
|
|
|
|
from .. import repo
|
|
|
|
from .. import repo
|
|
|
|
from .. import color
|
|
|
|
from .. import color
|
|
|
|
from ..uis import get_ui
|
|
|
|
from ..uis import get_ui
|
|
|
|
|
|
|
|
from ..utils import resolve_citekey_list
|
|
|
|
|
|
|
|
|
|
|
|
def parser(subparsers):
|
|
|
|
def parser(subparsers):
|
|
|
|
parser = subparsers.add_parser('remove', help='removes a paper')
|
|
|
|
parser = subparsers.add_parser('remove', help='removes a publication')
|
|
|
|
parser.add_argument('-f', '--force', action='store_true', default=None,
|
|
|
|
parser.add_argument('-f', '--force', action='store_true', default=None,
|
|
|
|
help="does not prompt for confirmation.")
|
|
|
|
help="does not prompt for confirmation.")
|
|
|
|
parser.add_argument('citekeys', nargs='*',
|
|
|
|
parser.add_argument('citekeys', nargs='+',
|
|
|
|
help="one or several citekeys")
|
|
|
|
help="one or several citekeys")
|
|
|
|
return parser
|
|
|
|
return parser
|
|
|
|
|
|
|
|
|
|
|
@ -18,15 +18,23 @@ def command(conf, args):
|
|
|
|
force = args.force
|
|
|
|
force = args.force
|
|
|
|
rp = repo.Repository(conf)
|
|
|
|
rp = repo.Repository(conf)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
keys = resolve_citekey_list(repo=rp, citekeys=args.citekeys, ui=ui, exit_on_fail=True)
|
|
|
|
|
|
|
|
|
|
|
|
if force is None:
|
|
|
|
if force is None:
|
|
|
|
are_you_sure = (("Are you sure you want to delete paper(s) [{}]"
|
|
|
|
are_you_sure = (("Are you sure you want to delete the publication(s) [{}]"
|
|
|
|
" (this will also delete associated documents)?")
|
|
|
|
" (this will also delete associated documents)?")
|
|
|
|
.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
|
|
|
.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
|
|
|
sure = ui.input_yn(question=are_you_sure, default='n')
|
|
|
|
sure = ui.input_yn(question=are_you_sure, default='n')
|
|
|
|
if force or sure:
|
|
|
|
if force or sure:
|
|
|
|
for c in args.citekeys:
|
|
|
|
for c in keys:
|
|
|
|
|
|
|
|
try:
|
|
|
|
rp.remove_paper(c)
|
|
|
|
rp.remove_paper(c)
|
|
|
|
ui.message('The paper(s) [{}] were removed'.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
ui.error(e.message)
|
|
|
|
|
|
|
|
ui.message('The publication(s) [{}] were removed'.format(
|
|
|
|
|
|
|
|
', '.join([color.dye_out(c, 'citekey') for c in keys])))
|
|
|
|
# FIXME: print should check that removal proceeded well.
|
|
|
|
# FIXME: print should check that removal proceeded well.
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
ui.message('The paper(s) [{}] were *not* removed'.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
|
|
|
ui.message('The publication(s) [{}] were {} removed'.format(
|
|
|
|
|
|
|
|
', '.join([color.dye_out(c, 'citekey') for c in keys]),
|
|
|
|
|
|
|
|
color.dye_out('not','bold')))
|
|
|
|