From a2cc75d2c701975ece6d6e08d7d40dfee0136ee1 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 27 Jun 2009 21:23:45 -0400 Subject: [PATCH] Enhancement - confirmation - Added tri-state confirmation to append command. --- src/command.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index f61c17ea2..75a37c061 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -872,6 +872,10 @@ std::string handleAppend () std::vector all = tasks; context.filter.applySequence (tasks, context.sequence); + Permission permission; + if (context.sequence.size () > (size_t) context.config.get ("bulk", 2)) + permission.bigSequence (); + foreach (task, tasks) { foreach (other, all) @@ -881,6 +885,8 @@ std::string handleAppend () task->get ("parent") == other->get ("parent")) || // Sibling other->get ("uuid") == task->get ("parent")) // Parent { + Task before (*other); + // A non-zero value forces a file write. int changes = 0; @@ -889,19 +895,23 @@ std::string handleAppend () changes += deltaTags (*other); changes += deltaAttributes (*other); - if (changes) + if (taskDiff (before, *other)) { - context.tdb.update (*other); + std::string question = taskDifferences (before, *other) + "Are you sure?"; + if (changes && permission.confirmed (question)) + { + context.tdb.update (*other); - if (context.config.get ("echo.command", true)) - out << "Appended '" - << context.task.get ("description") - << "' to task " - << other->id - << std::endl; + if (context.config.get ("echo.command", true)) + out << "Appended '" + << context.task.get ("description") + << "' to task " + << other->id + << std::endl; + + ++count; + } } - - ++count; } } }