Feature - #283 verbosity of annotations

- the configuration variable annotation.details now controls the
  verbosity of the output of annotations.
This commit is contained in:
Federico Hernandez 2010-01-14 00:03:52 +01:00
parent b001c2f40b
commit 3aae7b180b
6 changed files with 97 additions and 21 deletions

View file

@ -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"

View file

@ -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 "

View file

@ -2113,12 +2113,32 @@ std::string getFullDescription (Task& task)
std::vector <Att> 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;
}

View file

@ -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';