From 5609711d47fbf04d9f832e17d6e8615c322e5717 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 29 Jan 2012 18:28:07 -0500 Subject: [PATCH] Feature #571 - Special tag feedback - The verbosity token 'special' now controls whether the feedback is provided when special tags are added to a task. - Added new 'special' verbosity token documentation to man page. - Added missing 'next' special tag to man page. - Added new localized strings for describing special tags. --- ChangeLog | 2 ++ doc/man/task.1.in | 1 + doc/man/taskrc.5.in | 1 + src/Config.cpp | 2 +- src/commands/Command.cpp | 3 +++ src/en-US.h | 4 ++++ src/feedback.cpp | 25 +++++++++++++++++++++++++ src/main.h | 1 + test/verbose.t | 1 + 9 files changed, 39 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6bba84c40..90a1b4704 100644 --- a/ChangeLog +++ b/ChangeLog @@ -71,6 +71,8 @@ + Added feature #559, that causes Taskwarrior to exit if the ~/.task (or rc.data.location override) does not exist, controlled by the rc.exit.on.missing.db configuration variable (thanks to Sander Marechal). + + Added feature #571, which provides descriptive feedback when a special tag + is applied. + Added feature #607, which allows modification of a task during annotation (thanks to Peter De Poorter). + Added feature #612, so that the 'info' command displays the sum of all diff --git a/doc/man/task.1.in b/doc/man/task.1.in index c130d92e6..e0a7fd394 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -487,6 +487,7 @@ exempt from all color rules. The supported special tags are: +nocolor Disable color rules processing for this task +nonag Completion of this task suppresses all nag messages +nocal This task will not appear on the calendar + +next Elevates task so it appears on 'next' report .TP .B project: diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 138b117a2..f0c9c1a25 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -225,6 +225,7 @@ control specific occasions when output is generated. This list may contain: new-id Provides feedback of any new task IDs affected Reports 'N tasks affected' and similar edit Used the verbose template for the 'edit' command + special Feedback when applying special tags Note that the "on" setting is equivalent to all the tokens being specified, and the "off" setting is equivalent to none of the tokens being specified. diff --git a/src/Config.cpp b/src/Config.cpp index 321cd6828..5234d593e 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -82,7 +82,7 @@ std::string Config::_defaults = "verbose=yes # Provide maximal feedback\n" "#verbose=no # Provide minimal feedback\n" "#verbose=list # Comma-separated list. May contain any subset of:\n" - "#verbose=blank,header,footnote,label,new-id,affected,edit\n" + "#verbose=blank,header,footnote,label,new-id,affected,edit,special\n" "confirmation=yes # Confirmation on delete, big changes\n" "echo.command=yes # Details on command just run. Deprecated\n" "annotations=full # Level of verbosity for annotations: full, sparse or none\n" diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 416b9faf9..8547504ec 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -520,7 +520,10 @@ void Command::modify_task ( A3::extract_tag (arg._raw, type, value); if (type == '+') + { task.addTag (value); + feedback_special_tags (task, value); + } else task.removeTag (value); } diff --git a/src/en-US.h b/src/en-US.h index ad5d8a753..23900146b 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -680,6 +680,10 @@ #define STRING_FEEDBACK_ANN_WAS_MOD "Annotation changed to '{1}'." #define STRING_FEEDBACK_NOP "No changes will be made." #define STRING_FEEDBACK_WAS_NOP "No changes made." +#define STRING_FEEDBACK_TAG_NOCOLOR "The 'nocolor' special tag will disable color rules for this task." +#define STRING_FEEDBACK_TAG_NONAG "The 'nonag' special tag will prevent nagging when this task is modified." +#define STRING_FEEDBACK_TAG_NOCAL "The 'nocal' special tag will keep this task off the calendar report." +#define STRING_FEEDBACK_TAG_NEXT "The 'next' special tag will boost the urgency of this task so it appears on the 'next' report." // File #define STRING_FILE_PERMS "Task does not have the correct permissions for '{1}'." diff --git a/src/feedback.cpp b/src/feedback.cpp index 785ab7304..95be99f3c 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -340,4 +340,29 @@ void feedback_affected (const std::string& effect, const Task& task) } //////////////////////////////////////////////////////////////////////////////// +// Implements feedback when adding special tags to a task. +void feedback_special_tags (const Task& task, const std::string& tag) +{ + if (context.verbose ("special")) + { + std::string msg; + std::string explanation; + if (tag == "nocolor") msg = STRING_FEEDBACK_TAG_NOCOLOR; + else if (tag == "nonag") msg = STRING_FEEDBACK_TAG_NONAG; + else if (tag == "nocal") msg = STRING_FEEDBACK_TAG_NOCAL; + else if (tag == "next") msg = STRING_FEEDBACK_TAG_NEXT; + + if (msg.length ()) + { + if (task.id) + std::cout << format (msg, task.id) + << "\n"; + else + std::cout << format (msg, task.get ("uuid")) + << "\n"; + } + } +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/main.h b/src/main.h index f83b83224..0a336af47 100644 --- a/src/main.h +++ b/src/main.h @@ -77,6 +77,7 @@ std::string renderAttribute (const std::string&, const std::string&); void feedback_affected (const std::string&); void feedback_affected (const std::string&, int); void feedback_affected (const std::string&, const Task&); +void feedback_special_tags (const Task&, const std::string&); // sort.cpp void sort_tasks (std::vector &, std::vector &, const std::string&); diff --git a/test/verbose.t b/test/verbose.t index 4c79a92cb..832c3de51 100755 --- a/test/verbose.t +++ b/test/verbose.t @@ -65,6 +65,7 @@ unlike ($output, qr/^\d+ tasks$/ms, '\'footer\' verbosity good'); # TODO Verbosity: 'blank' # TODO Verbosity: 'header' # TODO Verbosity: 'edit' +# TODO Verbosity: 'special' # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data synch.key verbose.rc);