From 1b54516b45d4b9b53785e45ddbb897fd37e1ba33 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 14 Oct 2011 02:13:18 -0400 Subject: [PATCH] Confirmation - Implemented consistent confirmation. --- src/commands/CmdAnnotate.cpp | 2 +- src/commands/CmdAppend.cpp | 2 +- src/commands/CmdPrepend.cpp | 49 +++++++----------------------------- src/en-US.h | 16 ++++++------ 4 files changed, 19 insertions(+), 50 deletions(-) diff --git a/src/commands/CmdAnnotate.cpp b/src/commands/CmdAnnotate.cpp index 43feaf986..ec45fbb3e 100644 --- a/src/commands/CmdAnnotate.cpp +++ b/src/commands/CmdAnnotate.cpp @@ -65,7 +65,7 @@ int CmdAnnotate::execute (std::string& output) // Apply the command line modifications to the new task. A3 modifications = context.a3.extract_modifications (); if (!modifications.size ()) - throw std::string (STRING_CMD_XPEND_NEED_TEXT); + throw std::string (STRING_CMD_MODIFY_NEED_TEXT); std::vector ::iterator task; for (task = filtered.begin (); task != filtered.end (); ++task) diff --git a/src/commands/CmdAppend.cpp b/src/commands/CmdAppend.cpp index 97fa8282a..4a2c404e1 100644 --- a/src/commands/CmdAppend.cpp +++ b/src/commands/CmdAppend.cpp @@ -65,7 +65,7 @@ int CmdAppend::execute (std::string& output) // Apply the command line modifications to the new task. A3 modifications = context.a3.extract_modifications (); if (!modifications.size ()) - throw std::string (STRING_CMD_XPEND_NEED_TEXT); + throw std::string (STRING_CMD_MODIFY_NEED_TEXT); std::vector ::iterator task; for (task = filtered.begin (); task != filtered.end (); ++task) diff --git a/src/commands/CmdPrepend.cpp b/src/commands/CmdPrepend.cpp index 1a943b916..1436934b0 100644 --- a/src/commands/CmdPrepend.cpp +++ b/src/commands/CmdPrepend.cpp @@ -25,12 +25,10 @@ // //////////////////////////////////////////////////////////////////////////////// - #define L10N // Localization complete. -#include +#include #include -#include #include #include #include @@ -54,7 +52,6 @@ int CmdPrepend::execute (std::string& output) { int rc = 0; int count = 0; - std::stringstream out; // Apply filter. std::vector filtered; @@ -68,11 +65,7 @@ int CmdPrepend::execute (std::string& output) // Apply the command line modifications to the new task. A3 modifications = context.a3.extract_modifications (); if (!modifications.size ()) - throw std::string (STRING_CMD_XPEND_NEED_TEXT); - - Permission permission; - if (filtered.size () > (size_t) context.config.getInteger ("bulk")) - permission.bigSequence (); + throw std::string (STRING_CMD_MODIFY_NEED_TEXT); std::vector ::iterator task; for (task = filtered.begin (); task != filtered.end (); ++task) @@ -80,26 +73,17 @@ int CmdPrepend::execute (std::string& output) Task before (*task); // Prepend to the specified task. - std::string question = format (STRING_CMD_PREPEND_QUESTION, + std::string question = format (STRING_CMD_PREPEND_CONFIRM, task->id, task->get ("description")); modify_task_description_prepend (*task, modifications); - if (permission.confirmed (*task, taskDifferences (before, *task) + question)) + if (permission (*task, taskDifferences (before, *task) + question, filtered.size ())) { context.tdb2.modify (*task); ++count; - - if (context.verbose ("affected") || - context.config.getBoolean ("echo.command")) // Deprecated 2.0 - out << format (task->has ("parent") - ? STRING_CMD_PREPEND_RECURRING - : STRING_CMD_PREPEND_DELETING, - task->id, - task->get ("description")) - << "\n"; - + feedback_affected (STRING_CMD_PREPEND_TASK, *task); context.footnote (onProjectChange (*task, true)); // Prepend to siblings. @@ -107,7 +91,7 @@ int CmdPrepend::execute (std::string& output) { std::vector siblings = context.tdb2.siblings (*task); if (siblings.size () && - confirm (STRING_CMD_PREPEND_CONF_REC)) + confirm (STRING_CMD_PREPEND_CONFIRM_R)) { std::vector ::iterator sibling; for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling) @@ -115,13 +99,7 @@ int CmdPrepend::execute (std::string& output) modify_task_description_prepend (*sibling, modifications); context.tdb2.modify (*sibling); ++count; - - if (context.verbose ("affected") || - context.config.getBoolean ("echo.command")) // Deprecated 2.0 - out << format (STRING_CMD_PREPEND_RECURRING, - sibling->id, - sibling->get ("description")) - << "\n"; + feedback_affected (STRING_CMD_PREPEND_TASK_R, *sibling); } // Prepend to the parent @@ -134,22 +112,13 @@ int CmdPrepend::execute (std::string& output) } else { - out << STRING_CMD_DELETE_NOT << "\n"; + std::cout << STRING_CMD_PREPEND_NO << "\n"; rc = 1; } } context.tdb2.commit (); - - if (context.verbose ("affected") || - context.config.getBoolean ("echo.command")) // Deprecated 2.0 - out << format ((count == 1 - ? STRING_CMD_PREPEND_SUMMARY - : STRING_CMD_PREPEND_SUMMARY_N), - count) - << "\n"; - - output = out.str (); + feedback_affected (count == 1 ? STRING_CMD_PREPEND_1 : STRING_CMD_PREPEND_N, count); return rc; } diff --git a/src/en-US.h b/src/en-US.h index 65a96feda..22fd7ed68 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -320,8 +320,6 @@ #define STRING_CMD_STOP_STOPPED "Stopped {1} task." #define STRING_CMD_STOP_STOPPED_N "Stopped {1} tasks." -#define STRING_CMD_DELETE_NOTPEND "Task {1} '{2}' is neither pending nor waiting." - #define STRING_CMD_APPEND_USAGE "Appends text to an existing task description" #define STRING_CMD_APPEND_1 "Appended {1} task." #define STRING_CMD_APPEND_N "Appended {1} tasks." @@ -333,13 +331,14 @@ #define STRING_CMD_APPEND_NO "Task not appended." #define STRING_CMD_PREPEND_USAGE "Prepends text to an existing task description" -#define STRING_CMD_PREPEND_SUMMARY "Prepended {1} task." -#define STRING_CMD_PREPEND_SUMMARY_N "Prepended {1} tasks." -#define STRING_CMD_PREPEND_QUESTION "Prepend to task {1} '{2}'?" -#define STRING_CMD_PREPEND_RECURRING "Prepending to recurring task {1} '{2}'." +#define STRING_CMD_PREPEND_1 "Prepended {1} task." +#define STRING_CMD_PREPEND_N "Prepended {1} tasks." +#define STRING_CMD_PREPEND_TASK "Prepending to task {1} '{2}'." +#define STRING_CMD_PREPEND_TASK_R "Prepending to recurring task {1} '{2}'." #define STRING_CMD_PREPEND_DELETING "Prepending to task {1} '{2}'." -#define STRING_CMD_PREPEND_CONF_REC "This is a recurring task. Do you want to prepend to all pending recurrences of this same task?" -#define STRING_CMD_XPEND_NEED_TEXT "Additional text must be provided." +#define STRING_CMD_PREPEND_CONFIRM_R "This is a recurring task. Do you want to prepend to all pending recurrences of this same task?" +#define STRING_CMD_PREPEND_CONFIRM "Prepend to task {1} '{2}'?" +#define STRING_CMD_PREPEND_NO "Task not prepended." #define STRING_CMD_ANNO_USAGE "Adds an annotation to an existing task" #define STRING_CMD_ANNO_CONFIRM "Annotate task {1} '{2}'?" @@ -419,6 +418,7 @@ #define STRING_CMD_MODIFY_SIMPLE "Modiying task {1} '{2}'." #define STRING_CMD_MODIFY_NOT "Task not modified." #define STRING_CMD_MODIFY_RECUR "This is a recurring task. Do you want to modify all pending recurrences of this same task?" +#define STRING_CMD_MODIFY_NEED_TEXT "Additional text must be provided." #define STRING_CMD_COLOR_USAGE "Displays all possible colors, a named sample, or a legend containing all currently defined colors" #define STRING_CMD_COLOR_HERE "Here are the colors currently in use:" #define STRING_CMD_COLOR_COLOR "Color"