From 8d76eaca88f8568e71c0ef01e30a6123e5467f5f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 27 Jun 2009 21:31:11 -0400 Subject: [PATCH] Enhancement - Implemented tri-state confirmation in the annotate command. --- src/command.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index 75a37c061..973b187f0 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1172,18 +1172,31 @@ std::string handleAnnotate () // Filter sequence. context.filter.applySequence (tasks, context.sequence); + Permission permission; + if (context.sequence.size () > (size_t) context.config.get ("bulk", 2)) + permission.bigSequence (); + foreach (task, tasks) { + Task before (*task); task->addAnnotation (context.task.get ("description")); - context.tdb.update (*task); - if (context.config.get ("echo.command", true)) - out << "Annotated " - << task->id - << " with '" - << 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 << "Annotated " + << task->id + << " with '" + << task->get ("description") + << "'" + << std::endl; + } + } } context.tdb.commit ();