diff --git a/src/commands/CmdAppend.cpp b/src/commands/CmdAppend.cpp index 9db0e0ef7..97fa8282a 100644 --- a/src/commands/CmdAppend.cpp +++ b/src/commands/CmdAppend.cpp @@ -27,9 +27,8 @@ #define L10N // Localization complete. -#include +#include #include -#include #include #include #include @@ -53,7 +52,6 @@ int CmdAppend::execute (std::string& output) { int rc = 0; int count = 0; - std::stringstream out; // Apply filter. std::vector filtered; @@ -69,36 +67,23 @@ int CmdAppend::execute (std::string& output) if (!modifications.size ()) throw std::string (STRING_CMD_XPEND_NEED_TEXT); - Permission permission; - if (filtered.size () > (size_t) context.config.getInteger ("bulk")) - permission.bigSequence (); - std::vector ::iterator task; for (task = filtered.begin (); task != filtered.end (); ++task) { Task before (*task); // Append to the specified task. - std::string question = format (STRING_CMD_APPEND_QUESTION, + std::string question = format (STRING_CMD_APPEND_CONFIRM, task->id, task->get ("description")); modify_task_description_append (*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_APPEND_RECURRING - : STRING_CMD_APPEND_DELETING, - task->id, - task->get ("description")) - << "\n"; - + feedback_affected (STRING_CMD_APPEND_TASK, *task); context.footnote (onProjectChange (*task, true)); // Append to siblings. @@ -106,7 +91,7 @@ int CmdAppend::execute (std::string& output) { std::vector siblings = context.tdb2.siblings (*task); if (siblings.size () && - confirm (STRING_CMD_APPEND_CONF_RECUR)) + confirm (STRING_CMD_APPEND_CONFIRM_R)) { std::vector ::iterator sibling; for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling) @@ -114,13 +99,7 @@ int CmdAppend::execute (std::string& output) modify_task_description_append (*sibling, modifications); context.tdb2.modify (*sibling); ++count; - - if (context.verbose ("affected") || - context.config.getBoolean ("echo.command")) // Deprecated 2.0 - out << format (STRING_CMD_APPEND_RECURRING, - sibling->id, - sibling->get ("description")) - << "\n"; + feedback_affected (STRING_CMD_APPEND_TASK_R, *sibling); } // Append to the parent @@ -133,22 +112,13 @@ int CmdAppend::execute (std::string& output) } else { - out << STRING_CMD_DELETE_NOT << "\n"; + std::cout << STRING_CMD_APPEND_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_APPEND_SUMMARY - : STRING_CMD_APPEND_SUMMARY_N), - count) - << "\n"; - - output = out.str (); + feedback_affected (count == 1 ? STRING_CMD_APPEND_1 : STRING_CMD_APPEND_N, count); return rc; } diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index 1a781cdf7..078720c28 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -52,7 +52,6 @@ int CmdDelete::execute (std::string& output) { int rc = 0; int count = 0; - //std::stringstream out; // Apply filter. std::vector filtered; @@ -89,7 +88,7 @@ int CmdDelete::execute (std::string& output) updateRecurrenceMask (*task); context.tdb2.modify (*task); ++count; - feedback_affected (STRING_CMD_DELETE_TASK *task); + feedback_affected (STRING_CMD_DELETE_TASK, *task); dependencyChainOnComplete (*task); context.footnote (onProjectChange (*task, true)); diff --git a/src/en-US.h b/src/en-US.h index 0c63240d8..65a96feda 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -319,13 +319,19 @@ #define STRING_CMD_STOP_QUESTION "Stop task {1} '{2}'?" #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_SUMMARY "Appended {1} task." -#define STRING_CMD_APPEND_SUMMARY_N "Appended {1} tasks." -#define STRING_CMD_APPEND_QUESTION "Append to task {1} '{2}'?" -#define STRING_CMD_APPEND_RECURRING "Appending to recurring task {1} '{2}'." +#define STRING_CMD_APPEND_1 "Appended {1} task." +#define STRING_CMD_APPEND_N "Appended {1} tasks." +#define STRING_CMD_APPEND_TASK "Appending to task {1} '{2}'." +#define STRING_CMD_APPEND_TASK_R "Appending to recurring task {1} '{2}'." #define STRING_CMD_APPEND_DELETING "Appending to task {1} '{2}'." -#define STRING_CMD_APPEND_CONF_RECUR "This is a recurring task. Do you want to append to all pending recurrences of this same task?" +#define STRING_CMD_APPEND_CONFIRM_R "This is a recurring task. Do you want to append to all pending recurrences of this same task?" +#define STRING_CMD_APPEND_CONFIRM "Append to task {1} '{2}'?" +#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."