From 3aae7b180b858aa3f71430a541a9b3e5dd1fee6c Mon Sep 17 00:00:00 2001 From: Federico Hernandez Date: Thu, 14 Jan 2010 00:03:52 +0100 Subject: [PATCH] Feature - #283 verbosity of annotations - the configuration variable annotation.details now controls the verbosity of the output of annotations. --- ChangeLog | 6 ++-- doc/man/taskrc.5 | 4 +++ src/Config.cpp | 1 + src/command.cpp | 4 +-- src/report.cpp | 32 ++++++++++++++++---- src/tests/annotate.t | 71 +++++++++++++++++++++++++++++++++++++------- 6 files changed, 97 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ba115dda..741de875f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,11 +2,13 @@ ------ current release --------------------------- 1.9.0 () - + Added feature #292 that permits alternate line coloration in reports - (thanks to Richard Querin). + + Added feature #283 that makes it possible to control the verbosity + of the output of annotations. + Added feature #254 (#295) which gives task a second date format to be used in the reports with more conversion sequences like weekday name or weeknumber. The date format is set with variable "reportdateformat". + + Added feature #292 that permits alternate line coloration in reports + (thanks to Richard Querin). + Added feature #307 that provides vim with syntax highlighting for .taskrc. + Added feature #336 which gives task a 'prepend' command for symmetry with the 'append' command. diff --git a/doc/man/taskrc.5 b/doc/man/taskrc.5 index 4e5f1bc59..c3f705b1e 100644 --- a/doc/man/taskrc.5 +++ b/doc/man/taskrc.5 @@ -115,6 +115,10 @@ May be "yes" or "no", and determines whether task will ask for confirmation befo .B echo.command=yes May be "yes" or "no", and causes task to display the ID and description of any task when you run the start, stop, do, undo or delete commands. The default value is "yes". +.TP +.B annotation.details=2 +Controls the output of annotations in reports. Defaults to 2 - all annotations are displayed. Set to 1 only the last (youngest) annotation is displayed and if there are more than one present for a task a "+" sign is added to the description. Set to 0 the output of annotations is disabled and a "+" sign will be added if there are any annotations present. + .TP .B next=2 Is a number, defaulting to 2, which is the number of tasks for each project that are shown in the diff --git a/src/Config.cpp b/src/Config.cpp index 32d1a87b4..486be85af 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -144,6 +144,7 @@ void Config::createDefaultRC (const std::string& rc, const std::string& data) << "# Miscellaneous\n" << "confirmation=yes # Confirmation on delete, big changes\n" << "echo.command=yes # Details on command just run\n" + << "annotation.details=2 # Level of verbosity for annotations in reports\n" << "next=2 # How many tasks per project in next report\n" << "bulk=2 # > 2 tasks considered 'a lot', for confirmation\n" << "nag=You have higher priority tasks. # Nag message to keep you honest\n" diff --git a/src/command.cpp b/src/command.cpp index 2fb9a5822..9907f9c53 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -551,8 +551,8 @@ int handleConfig (std::string &outs) // These are the regular configuration variables. // Note that there is a leading and trailing space, to make searching easier. std::string recognized = - " blanklines bulk calendar.details calendar.details.report color color.active " - "color.due color.overdue color.pri.H color.pri.L color.pri.M color.pri.none " + " annotation.details blanklines bulk calendar.details calendar.details.report color " + "color.active color.due color.overdue color.pri.H color.pri.L color.pri.M color.pri.none " "color.recurring color.tagged color.footnote color.header color.debug color.alternate " "color.calendar.today color.calendar.due color.calendar.overdue color.calendar.weekend " "confirmation curses data.location dateformat reportdateformat debug default.command " diff --git a/src/report.cpp b/src/report.cpp index 06043674e..1b87f2645 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -2113,12 +2113,32 @@ std::string getFullDescription (Task& task) std::vector annotations; task.getAnnotations (annotations); - foreach (anno, annotations) - { - Date dt (atoi (anno->name ().substr (11).c_str ())); - std::string when = dt.toString (context.config.get ("dateformat", "m/d/Y")); - desc += "\n" + when + " " + anno->value (); - } + + if (annotations.size () != 0) + switch (context.config.get("annotation.details",2)) + { + case 0: + desc = "+" + desc; + break; + case 1: + { + if (annotations.size () > 1) + desc = "+" + desc; + Att anno (annotations.back()); + Date dt (atoi (anno.name ().substr (11).c_str ())); + std::string when = dt.toString (context.config.get ("dateformat", "m/d/Y")); + desc += "\n" + when + " " + anno.value (); + } + break; + case 2: + foreach (anno, annotations) + { + Date dt (atoi (anno->name ().substr (11).c_str ())); + std::string when = dt.toString (context.config.get ("dateformat", "m/d/Y")); + desc += "\n" + when + " " + anno->value (); + } + break; + } return desc; } diff --git a/src/tests/annotate.t b/src/tests/annotate.t index 69f35412d..7d5eb259e 100755 --- a/src/tests/annotate.t +++ b/src/tests/annotate.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 37; # Create the rc file. if (open my $fh, '>', 'annotate.rc') @@ -43,27 +43,76 @@ if (open my $fh, '>', 'annotate.rc') ok (-r 'annotate.rc', 'Created annotate.rc'); } -# Add two tasks, annotate one twice. +# Add four tasks, annotate one three times, one twice, one just once and one none. qx{../task rc:annotate.rc add one}; qx{../task rc:annotate.rc add two}; -qx{../task rc:annotate.rc annotate 1 foo}; -sleep 2; -qx{../task rc:annotate.rc annotate 1 bar}; +qx{../task rc:annotate.rc add three}; +qx{../task rc:annotate.rc add four}; +qx{../task rc:annotate.rc annotate 1 foo1}; +sleep 1; +qx{../task rc:annotate.rc annotate 1 foo2}; +sleep 1; +qx{../task rc:annotate.rc annotate 1 foo3}; +sleep 1; +qx{../task rc:annotate.rc annotate 2 bar1}; +sleep 1; +qx{../task rc:annotate.rc annotate 2 bar2}; +sleep 1; +qx{../task rc:annotate.rc annotate 3 baz1}; + my $output = qx{../task rc:annotate.rc rrr}; # ID Description # -- ------------------------------- # 1 one -# 3/24/2009 foo -# 3/24/2009 bar +# 3/24/2009 foo1 +# 3/24/2009 foo2 +# 3/24/2009 foo3 # 2 two +# 3/24/2009 bar1 +# 3/24/2009 bar2 +# 3 three +# 3/24/2009 baz1 +# 4 four # -# 2 tasks +# 4 tasks like ($output, qr/1 one/, 'task 1'); like ($output, qr/2 two/, 'task 2'); -like ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo/ms, 'first annotation'); -like ($output, qr/foo.+\d{1,2}\/\d{1,2}\/\d{4} bar/ms, 'second annotation'); -like ($output, qr/2 tasks/, 'count'); +like ($output, qr/3 three/, 'task 3'); +like ($output, qr/4 four/, 'task 4'); +like ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo1/ms, 'first annotation task 1'); +like ($output, qr/foo1.+\d{1,2}\/\d{1,2}\/\d{4} foo2/ms, 'second annotation task 1'); +like ($output, qr/foo2.+\d{1,2}\/\d{1,2}\/\d{4} foo3/ms, 'third annotation task 1'); +like ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar1/ms, 'first annotation task 2'); +like ($output, qr/bar1.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'second annotation task 2'); +like ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms,'first annotation task 3'); +like ($output, qr/4 tasks/, 'count'); + +$output = qx{../task rc:annotate.rc rc.annotation.details:1 rrr}; +like ($output, qr/1 \+one/, 'task 1'); +like ($output, qr/2 \+two/, 'task 2'); +like ($output, qr/3 three/, 'task 3'); +like ($output, qr/4 four/, 'task 4'); +unlike ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo1/ms, 'first annotation task 1'); +unlike ($output, qr/foo1.+\d{1,2}\/\d{1,2}\/\d{4} foo2/ms, 'second annotation task 1'); +like ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo3/ms, 'third annotation task 1'); +unlike ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar1/ms, 'first annotation task 2'); +like ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'second annotation task 2'); +like ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms, 'third annotation task 3'); +like ($output, qr/4 tasks/, 'count'); + +$output = qx{../task rc:annotate.rc rc.annotation.details:0 rrr}; +like ($output, qr/1 \+one/, 'task 1'); +like ($output, qr/2 \+two/, 'task 2'); +like ($output, qr/3 \+three/, 'task 3'); +like ($output, qr/4 four/, 'task 4'); +unlike ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo1/ms, 'first annotation task 1'); +unlike ($output, qr/foo1.+\d{1,2}\/\d{1,2}\/\d{4} foo2/ms, 'second annotation task 1'); +unlike ($output, qr/foo2.+\d{1,2}\/\d{1,2}\/\d{4} foo3/ms, 'third annotation task 1'); +unlike ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar1/ms, 'first annotation task 2'); +unlike ($output, qr/bar1.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'second annotation task 2'); +unlike ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms, 'third annotation task 3'); +like ($output, qr/4 tasks/, 'count'); # Cleanup. unlink 'pending.data';