diff --git a/src/commands/CmdDenotate.cpp b/src/commands/CmdDenotate.cpp index fd5c62cb4..7dee75348 100644 --- a/src/commands/CmdDenotate.cpp +++ b/src/commands/CmdDenotate.cpp @@ -27,9 +27,8 @@ #define L10N // Localization complete. -#include +#include #include -#include #include #include #include @@ -53,7 +52,6 @@ int CmdDenotate::execute (std::string& output) { int rc = 0; int count = 0; - std::stringstream out; bool sensitive = context.config.getBoolean ("search.case.sensitive"); // Apply filter. @@ -72,10 +70,6 @@ int CmdDenotate::execute (std::string& output) std::string pattern = words.combine (); - 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) { @@ -118,39 +112,26 @@ int CmdDenotate::execute (std::string& output) if (taskDiff (before, *task)) { - std::string question = format (STRING_CMD_DENO_QUESTION, + std::string question = format (STRING_CMD_DENO_CONFIRM, task->id, task->get ("description")); - if (permission.confirmed (*task, taskDifferences (before, *task) + question)) + if (permission (*task, taskDifferences (before, *task) + question, filtered.size ())) { ++count; context.tdb2.modify (*task); - if (context.verbose ("affected") || - context.config.getBoolean ("echo.command")) // Deprecated 2.0 - out << format (STRING_CMD_DENO_FOUND, anno) - << "\n"; + feedback_affected (format (STRING_CMD_DENO_FOUND, anno)); } } else { - out << format (STRING_CMD_DENO_NOMATCH, pattern) - << "\n"; + std::cout << format (STRING_CMD_DENO_NOMATCH, pattern) << "\n"; rc = 1; } } context.tdb2.commit (); - - if (context.verbose ("affected") || - context.config.getBoolean ("echo.command")) // Deprecated 2.0 - out << format ((count == 1 - ? STRING_CMD_DENO_TASK - : STRING_CMD_DENO_TASKS), - count) - << "\n"; - - output = out.str (); + feedback_affected (count == 1 ? STRING_CMD_DENO_1 : STRING_CMD_DENO_N, count); return rc; } diff --git a/src/en-US.h b/src/en-US.h index 22fd7ed68..5daffffbb 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -325,7 +325,6 @@ #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_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." @@ -335,7 +334,6 @@ #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_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." @@ -352,14 +350,16 @@ #define STRING_CMD_COLUMNS_USAGE "Displays all supported columns and formatting styles" #define STRING_CMD_COLUMNS_NOTE "* Means default format, and therefore optional. For example, 'due' and 'due.formatted' are equivalent." #define STRING_CMD_COLUMNS_USAGE2 "Displays only a list of supported columns" + #define STRING_CMD_DENO_USAGE "Deletes an annotation" #define STRING_CMD_DENO_WORDS "An annotation pattern must be provided." #define STRING_CMD_DENO_NONE "The specified task has no annotations that can be deleted." +#define STRING_CMD_DENO_CONFIRM "Denotate task {1} '{2}'?" #define STRING_CMD_DENO_FOUND "Found annotation '{1}' and deleted it." #define STRING_CMD_DENO_NOMATCH "Did not find any matching annotation to be deleted for '{1}'." -#define STRING_CMD_DENO_TASK "Denotated {1} task." -#define STRING_CMD_DENO_TASKS "Denotated {1} tasks." -#define STRING_CMD_DENO_QUESTION "Denotate task {1} '{2}'?" +#define STRING_CMD_DENO_1 "Denotated {1} task." +#define STRING_CMD_DENO_N "Denotated {1} tasks." + #define STRING_CMD_IMPORT_USAGE "Imports JSON files" #define STRING_CMD_IMPORT_SUMMARY "Imported {1} tasks." #define STRING_CMD_IMPORT_NOFILE "You must specify a file to import." diff --git a/src/feedback.cpp b/src/feedback.cpp index 2b3c32a69..f35f36a45 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -295,6 +295,18 @@ std::string renderAttribute (const std::string& name, const std::string& value) return value; } +//////////////////////////////////////////////////////////////////////////////// +// Implements: +// +void feedback_affected (const std::string& effect) +{ + if (context.verbose ("affected") || + context.config.getBoolean ("echo.command")) // Deprecated 2.0 + { + std::cout << effect << "\n"; + } +} + //////////////////////////////////////////////////////////////////////////////// // Implements: // Deleted 3 tasks diff --git a/src/main.h b/src/main.h index f09c4a725..40bdb5b94 100644 --- a/src/main.h +++ b/src/main.h @@ -74,8 +74,9 @@ bool taskDiff (const Task&, const Task&); std::string taskDifferences (const Task&, const Task&); std::string taskInfoDifferences (const Task&, const Task&); std::string renderAttribute (const std::string&, const std::string&); -void feedback_affected (const std::string&, const Task&); +void feedback_affected (const std::string&); void feedback_affected (const std::string&, int); +void feedback_affected (const std::string&, const Task&); // sort.cpp void sort_tasks (std::vector &, std::vector &, const std::string&);