From 564801acd608513adb07244829735ffb2669685d Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 15 Sep 2016 15:01:48 +0300 Subject: Don't prompt if build/drop plan is obvious --- bpkg/pkg-drop.cxx | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'bpkg/pkg-drop.cxx') diff --git a/bpkg/pkg-drop.cxx b/bpkg/pkg-drop.cxx index d623b68..065d652 100644 --- a/bpkg/pkg-drop.cxx +++ b/bpkg/pkg-drop.cxx @@ -299,11 +299,12 @@ namespace bpkg bool print_only, bool disfigure_only, bool yes, - bool no) + bool no, + bool print_plan) { // Print what we are going to do, then ask for the user's confirmation. // - if (print_only || !(yes || no)) + if (print_only || !(yes || no || !print_plan)) { for (const drop_package& dp: pkgs) { @@ -328,7 +329,7 @@ namespace bpkg // Ask the user if we should continue. // - if (no || !(yes || yn_prompt ("continue? [Y/n]", 'y'))) + if (no || !(yes || !print_plan || yn_prompt ("continue? [Y/n]", 'y'))) return 1; // All that's left to do is first disfigure configured packages and @@ -433,6 +434,12 @@ namespace bpkg // drop_packages pkgs; bool drop_prq (false); + + // Print the plan and ask for the user's confirmation only if there are + // additional packages (such as dependents or prerequisites of the + // explicitly listed packages) to be dropped. + // + bool print_plan (false); { transaction t (db.begin ()); @@ -486,6 +493,8 @@ namespace bpkg if (o.no () || !yn_prompt ("drop dependent packages? [y/N]", 'n')) return 1; + + print_plan = true; } // Collect all the prerequisites that are not held. These will be @@ -541,6 +550,9 @@ namespace bpkg } drop_prq = yn_prompt ("drop prerequisite packages? [Y/n]", 'y'); + + if (drop_prq) + print_plan = true; } t.commit (); @@ -554,7 +566,8 @@ namespace bpkg o.print_only (), o.disfigure_only (), o.yes (), - o.no ()); + o.no (), + print_plan); } set> @@ -623,7 +636,8 @@ namespace bpkg false, // Print-only (too late for that). false, // Disfigure-only (could be an option). true, // Yes (don't print the plan or prompt). - false); // No (we already said yes). + false, // No (we already said yes). + false); // Don't print the plan (just to reiterate). set> r; for (const drop_package& dp: pkgs) -- cgit v1.1