From 90b61089b150a5162255dbbeac6c70048fdd6ed0 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Fri, 8 May 2020 11:42:02 +0900 Subject: [PATCH] improve remove prompt (see #153) --- pubs/commands/remove_cmd.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pubs/commands/remove_cmd.py b/pubs/commands/remove_cmd.py index 0b7f9e0..cad1fda 100644 --- a/pubs/commands/remove_cmd.py +++ b/pubs/commands/remove_cmd.py @@ -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')))