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

@ -2,6 +2,8 @@
------ current release ---------------------------
1.9.3 ()
+ Added feature #189, that records the start and stop times
as an annotation for a task.
+ Added feature #423, now custom report filters allow rc overrides.
+ Added feature #429, which improves the 'all' report to exclude deleted
tasks, provide a new sort order and include the 'end' column.

4
NEWS
View file

@ -1,7 +1,7 @@
New Features in task 1.9.3
-
- Start and stop times for a task can now be recorded as annotations.
-
Please refer to the ChangeLog file for full details. There are too many to
@ -14,7 +14,7 @@ New commands in task 1.9.3
New configuration options in task 1.9.3
-
- journal.time, journal.time.start.annotation, journal.time.stop.annotation
-
---

View file

@ -436,8 +436,23 @@ of the holidays is also shown. If set to sparse only the days are color-coded
and no details on the holidays will be displayed. The displaying of holidays is
turned off by setting the variable to none. The default value is "none".
.SS Journal entries
.TP
.B Holidays
.B journal.time=no
May be yes or no, and determines whether the 'start' and 'stop' commands should
record an annotation when being executed. The default value is "no". The text of
the corresponding annotations is controlled by
.TP journal.time.start.annotation=Started task
The text of the annotation that is recorded when executing the start command and
having set journal.time.
.TP journal.time.stop.annotation=Stopped task
The text of the annotation that is recorded when executing the stop command and
having set journal.time.
.SS Holidays
Holidays are entered either directly in the .taskrc file or via an include file
that is specified in .taskrc. For each holiday the name and the date is
required to be given:

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;