Feature #189 - annotation of start and stop times

- task can now record the invocation of the 'start' and 'stop'
  command as an annotation by setting journal.time to yes.
- the annoatation test can be customized with
  journal.time.start.annoation and
  journal.time.stop.annotation
This commit is contained in:
Federico Hernandez 2010-07-20 20:19:34 +02:00
parent 5ac0bd3800
commit 942f665d71
6 changed files with 84 additions and 10 deletions

View file

@ -96,6 +96,11 @@ std::string Config::defaults =
"calendar.holidays=none # Show public holidays on calendar:full, sparse or none\n"
"#monthsperline=3 # Number of calendar months on a line\n"
"\n"
"# Journal controls\n"
"journal.time=no # Record the invoking of the start/stop command as annotation\n"
"journal.time.start.annotation=Started task # Annotation description for the start journal entry\n"
"journal.time.stop.annotation=Stopped task # Annotation description for the stop journal entry\n"
"\n"
"# Color controls.\n"
"color=on # Enable color\n"
#ifdef LINUX

View file

@ -693,12 +693,12 @@ int handleShow (std::string &outs)
"color.undo.after confirmation curses data.location dateformat dateformat.holiday "
"dateformat.report dateformat.annotation debug default.command "
"default.priority default.project defaultwidth due locale displayweeknumber "
"export.ical.class echo.command fontunderline locking monthsperline nag "
"next project shadow.command shadow.file shadow.notify weekstart editor "
"import.synonym.id import.synonym.uuid complete.all.projects "
"complete.all.tags search.case.sensitive hooks active.indicator tag.indicator "
"recurrence.indicator recurrence.limit list.all.projects list.all.tags "
"undo.style "
"export.ical.class echo.command fontunderline locking monthsperline nag next "
"journal.time journal.time.start.annotation journal.time.stop.annotation "
"project shadow.command shadow.file shadow.notify weekstart editor "
"import.synonym.id import.synonym.uuid complete.all.projects complete.all.tags "
"search.case.sensitive hooks active.indicator tag.indicator recurrence.indicator "
"recurrence.limit list.all.projects list.all.tags undo.style "
#ifdef FEATURE_SHELL
"shell.prompt "
#endif
@ -1203,8 +1203,12 @@ int handleStart (std::string &outs)
{
char startTime[16];
sprintf (startTime, "%u", (unsigned int) time (NULL));
task->set ("start", startTime);
if (context.config.getBoolean ("journal.time"))
task->addAnnotation (context.config.get ("journal.time.start.annotation"));
context.tdb.update (*task);
if (context.config.getBoolean ("echo.command"))
@ -1263,6 +1267,10 @@ int handleStop (std::string &outs)
if (task->has ("start"))
{
task->remove ("start");
if (context.config.getBoolean ("journal.time"))
task->addAnnotation (context.config.get ("journal.time.stop.annotation"));
context.tdb.update (*task);
if (context.config.getBoolean ("echo.command"))

View file

@ -28,7 +28,7 @@
use strict;
use warnings;
use Test::More tests => 14;
use Test::More tests => 23;
# Create the rc file.
if (open my $fh, '>', 'start.rc')
@ -61,6 +61,46 @@ $output = qx{../task rc:start.rc active};
unlike ($output, qr/one/, 'one not active');
unlike ($output, qr/two/, 'two not active');
qx{../task rc:start.rc done 2};
$output = qx{../task rc:start.rc list};
unlike ($output, qr/two/, 'two deleted');
# Create the rc file.
if (open my $fh, '>', 'start2.rc')
{
print $fh "data.location=.\n";
print $fh "journal.time=on\n";
close $fh;
ok (-r 'start2.rc', 'Created start2.rc');
}
qx{../task rc:start2.rc start 1};
$output = qx{../task rc:start2.rc list};
like ($output, qr/Started task/, 'one start and annotated');
qx{../task rc:start2.rc stop 1};
$output = qx{../task rc:start2.rc list};
like ($output, qr/Stopped task/, 'one stopped and annotated');
# Create the rc file.
if (open my $fh, '>', 'start3.rc')
{
print $fh "data.location=.\n";
print $fh "journal.time=on\n";
print $fh "journal.time.start.annotation=Nu kör vi\n";
print $fh "journal.time.stop.annotation=Nu stannar vi\n";
close $fh;
ok (-r 'start3.rc', 'Created start3.rc');
}
qx{../task rc:start3.rc start 1};
$output = qx{../task rc:start3.rc list};
like ($output, qr/Nu kör vi/, 'one start and annotated with custom description');
qx{../task rc:start3.rc stop 1};
$output = qx{../task rc:start3.rc list};
like ($output, qr/Nu stannar vi/, 'one stopped and annotated with custom description');
# Cleanup.
ok (-r 'pending.data', 'Need to remove pending.data');
unlink 'pending.data';
@ -72,6 +112,10 @@ ok (!-r 'undo.data', 'Removed undo.data');
unlink 'start.rc';
ok (!-r 'start.rc', 'Removed start.rc');
unlink 'start2.rc';
ok (!-r 'start2.rc', 'Removed start2.rc');
unlink 'start3.rc';
ok (!-r 'start3.rc', 'Removed start3.rc');
exit 0;