mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Feature #298 - Configurable recurring task count
- Added new recurrence.limit value (default 1) to control the number of future pending tasks generated from a recurring parent task. - Added unit tests. - Updated taskrc man page.
This commit is contained in:
parent
78d092c588
commit
bb19361956
6 changed files with 79 additions and 1 deletions
|
@ -14,6 +14,8 @@
|
|||
+ Added feature #407, a new 'task show' command to display the current
|
||||
configuration settings or just the ones matching a search string.
|
||||
'task config' is now only used to set new configuration values.
|
||||
+ Added feature #298, supporting a configurable number of future recurring
|
||||
tasks that are generated.
|
||||
+ Fixed bug #406 so that task now includes command aliases in the _commands
|
||||
helper command used by shell completion scripts.
|
||||
+ Fixed bug #211 - it was unclear which commands modify a task description.
|
||||
|
|
|
@ -261,6 +261,13 @@ The character or string to show in the tag_indicator column. Defaults to +.
|
|||
.B recurrence.indicator=R
|
||||
The character or string to show in the recurrence_indicator column. Defaults to R.
|
||||
|
||||
.TP
|
||||
.B recurrence.limit=1
|
||||
The number of future recurring tasks to show. Defaults to 1. For example, if a
|
||||
weekly recurring task is added with a due date of tomorrow, and recurrence.limit
|
||||
is set to 2, then a report will list 2 pending recurring tasks, one for tomorrow,
|
||||
and one for a week from tomorrow.
|
||||
|
||||
.TP
|
||||
.B debug=off
|
||||
Task has a debug mode that causes diagnostic output to be displayed. Typically
|
||||
|
|
|
@ -75,6 +75,7 @@ std::string Config::defaults =
|
|||
"active.indicator=* # What to show as an active task indicator\n"
|
||||
"tag.indicator=+ # What to show as a tag indicator\n"
|
||||
"recurrence.indicator=R # What to show as a task recurrence indicator\n"
|
||||
"recurrence.limit=1 # Number of future recurring pending tasks\n"
|
||||
"\n"
|
||||
"# Dates\n"
|
||||
"dateformat=m/d/Y # Preferred input and display date format\n"
|
||||
|
|
|
@ -640,7 +640,7 @@ int handleShow (std::string &outs)
|
|||
"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.indicator recurrence.limit "
|
||||
#ifdef FEATURE_SHELL
|
||||
"shell.prompt "
|
||||
#endif
|
||||
|
|
|
@ -156,6 +156,8 @@ bool generateDueDates (Task& parent, std::vector <Date>& allDue)
|
|||
specificEnd = true;
|
||||
}
|
||||
|
||||
int recurrence_limit = context.config.getInteger ("recurrence.limit");
|
||||
int recurrence_counter = 0;
|
||||
Date now;
|
||||
for (Date i = due; ; i = getNextRecurrence (i, recur))
|
||||
{
|
||||
|
@ -175,6 +177,9 @@ bool generateDueDates (Task& parent, std::vector <Date>& allDue)
|
|||
}
|
||||
|
||||
if (i > now)
|
||||
++recurrence_counter;
|
||||
|
||||
if (recurrence_counter >= recurrence_limit)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
63
src/tests/recur.limit.t
Executable file
63
src/tests/recur.limit.t
Executable file
|
@ -0,0 +1,63 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 6;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'recur.rc')
|
||||
{
|
||||
print $fh "data.location=.\n";
|
||||
close $fh;
|
||||
ok (-r 'recur.rc', 'Created recur.rc');
|
||||
}
|
||||
|
||||
# Add a recurring task, then see how many future pending tasks are
|
||||
# generated by default, and by overriding rc.recurrence.limit.
|
||||
qx{../task rc:recur.rc add ONE due:tomorrow recur:weekly};
|
||||
my $output = qx{../task rc:recur.rc long};
|
||||
my @tasks = $output =~ /(ONE)/g;
|
||||
is (scalar @tasks, 1, 'recurrence.limit default to 1');
|
||||
|
||||
$output = qx{../task rc:recur.rc rc.recurrence.limit:4 long};
|
||||
@tasks = $output =~ /(ONE)/g;
|
||||
is (scalar @tasks, 4, 'recurrence.limit override to 4');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'recur.rc';
|
||||
ok (!-r 'recur.rc', 'Removed recur.rc');
|
||||
|
||||
exit 0;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue