From 3dcda73e0cdfbaf1d9b91602dd048a155e77654c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 27 Jun 2009 21:51:24 -0400 Subject: [PATCH] Enhancement - Implemented tri-state confirmation for done command. --- src/command.cpp | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index 973b187f0..109409fa7 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -679,13 +679,21 @@ std::string handleDone () 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 (); + bool nagged = false; foreach (task, tasks) { if (task->getStatus () == Task::pending) { - // Apply deltas. - deltaDescription (*task); + Task before (*task); + + // Apply other deltas. + if (deltaDescription (*task)) + permission.bigChange (); + deltaTags (*task); deltaAttributes (*task); deltaSubstitutions (*task); @@ -697,21 +705,29 @@ std::string handleDone () // Change status. task->setStatus (Task::completed); - context.tdb.update (*task); - if (context.config.get ("echo.command", true)) - out << "Completed " - << task->id - << " '" - << task->get ("description") - << "'" - << std::endl; + if (taskDiff (before, *task)) + { + std::string question = taskDifferences (before, *task) + "Are you sure?"; + if (permission.confirmed (question)) + { + context.tdb.update (*task); + + if (context.config.get ("echo.command", true)) + out << "Completed " + << task->id + << " '" + << task->get ("description") + << "'" + << std::endl; + + ++count; + } + } updateRecurrenceMask (all, *task); if (!nagged) nagged = nag (*task); - - ++count; } else out << "Task "