improve remove prompt (see #153)
This commit is contained in:
parent
4a27faf3ab
commit
90b61089b1
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from .. import repo
|
||||
from .. import color
|
||||
from .. import pretty
|
||||
from ..uis import get_ui
|
||||
from ..utils import resolve_citekey_list
|
||||
from ..p3 import ustr, u_maybe
|
||||
@ -25,11 +26,15 @@ def command(conf, args):
|
||||
rp = repo.Repository(conf)
|
||||
|
||||
keys = resolve_citekey_list(repo=rp, citekeys=args.citekeys, ui=ui, exit_on_fail=True)
|
||||
plural = 's' if len(keys) > 1 else ''
|
||||
|
||||
if force is None:
|
||||
are_you_sure = (("Are you sure you want to delete the publication(s) [{}]"
|
||||
" (this will also delete associated documents)?")
|
||||
.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
||||
to_remove_str = '\n'.join(pretty.paper_oneliner(rp.pull_paper(key),
|
||||
n_authors=conf['main']['n_authors'])
|
||||
for key in keys)
|
||||
are_you_sure = (("Are you sure you want to delete the following publication{}"
|
||||
" (this will also delete associated documents)?:\n{}\n")
|
||||
.format(plural, to_remove_str))
|
||||
sure = ui.input_yn(question=are_you_sure, default='n')
|
||||
if force or sure:
|
||||
failed = False # Whether something failed
|
||||
@ -42,11 +47,12 @@ def command(conf, args):
|
||||
if failed:
|
||||
ui.exit() # Exit with nonzero error code
|
||||
else:
|
||||
ui.message('The publication(s) [{}] were removed'.format(
|
||||
|
||||
ui.message('The publication{} {} were removed'.format(plural,
|
||||
', '.join([color.dye_out(c, 'citekey') for c in keys])))
|
||||
|
||||
# FIXME: print should check that removal proceeded well.
|
||||
else:
|
||||
ui.message('The publication(s) [{}] were {} removed'.format(
|
||||
ui.message('The publication{} {} were {} removed'.format(plural,
|
||||
', '.join([color.dye_out(c, 'citekey') for c in keys]),
|
||||
color.dye_out('not','bold')))
|
||||
|
Loading…
x
Reference in New Issue
Block a user