diff --git a/ChangeLog b/ChangeLog index 58e8f9970..ffff9a93e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/NEWS b/NEWS index 659f02c76..b0787dfb4 100644 --- a/NEWS +++ b/NEWS @@ -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 - --- diff --git a/doc/man/taskrc.5 b/doc/man/taskrc.5 index 24f767ead..0a442d507 100644 --- a/doc/man/taskrc.5 +++ b/doc/man/taskrc.5 @@ -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: diff --git a/src/Config.cpp b/src/Config.cpp index 6e0f18060..62708c775 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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 diff --git a/src/command.cpp b/src/command.cpp index 2af1f16c7..ac23c04e7 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -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")) diff --git a/src/tests/start.t b/src/tests/start.t index 06a051db9..baf3ca789 100755 --- a/src/tests/start.t +++ b/src/tests/start.t @@ -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;