- Added feature #574, default due dates (thanks to Erlan Sergaziev).
This commit is contained in:
Paul Beckingham 2010-12-24 00:28:06 -05:00
parent 05d664cae1
commit 879f0fed78
8 changed files with 46 additions and 4 deletions

View file

@ -69,4 +69,5 @@ suggestions:
Max Muller
Sander Marechal
Thomas Sattler
Erlan Sergaziev

View file

@ -21,6 +21,7 @@
intended to help scripts that manipulate task output.
+ Added feature #567, which makes it possible to apply an offset to the first
month to be displayed in the calendar report (thanks to Michelle Crane).
+ Added feature #574, default due dates (thanks to Erlan Sergaziev).
+ Added feature #575, including Danish holidays (thanks to Irfan Siddiqui).
+ Eliminated dependency on ncurses.
+ Fixed bug #515, which displayed an incorrect message after duplicating a

2
NEWS
View file

@ -40,6 +40,8 @@ New configuration options in taskwarrior 1.9.4
eliminates problems with task ID numbers for script writers.
- calendar.offset=off and calendar.offset.value=-1 to apply an offset value
to change the effective first month in the calendar report.
- default.due can be specified, and adds a default due date to all added
and imported tasks that don't otherwise have a due date.
Newly deprecated features in taskwarrior 1.9.4

View file

@ -833,6 +833,13 @@ Provides a default priority for the
.I task add
command, if you don't specify one. The default is blank.
.TP
.B
default.due=...
Provides a default due date for the
.I task add
command, if you don't specify one. The default is blank.
.TP
.B
default.command=list

View file

@ -241,6 +241,7 @@ std::string Config::defaults =
"\n"
"#default.project=foo # Default project for 'add' command\n"
"#default.priority=M # Default priority for 'add' command\n"
"#default.due=eom # Default due date for 'add' command\n"
"default.command=list # When no arguments are specified\n"
"\n"
"_forcecolor=no # Forces color to be on, even for non TTY output\n"

View file

@ -87,6 +87,15 @@ int handleAdd (std::string& outs)
context.task.set ("priority", defaultPriority);
}
// Override with default.due, if not specified.
if (context.task.get ("due") == "")
{
std::string defaultDue = context.config.get ("default.due");
if (defaultDue != "" &&
Att::validNameValue ("due", "", defaultDue))
context.task.set ("due", defaultDue);
}
// Include tags.
foreach (tag, context.tagAdditions)
context.task.addTag (*tag);
@ -181,6 +190,15 @@ int handleLog (std::string& outs)
context.task.set ("priority", defaultPriority);
}
// Override with default.due, if not specified.
if (context.task.get ("due") == "")
{
std::string defaultDue = context.config.get ("default.due");
if (defaultDue != "" &&
Att::validNameValue ("due", "", defaultDue))
context.task.set ("due", defaultDue);
}
// Include tags.
foreach (tag, context.tagAdditions)
context.task.addTag (*tag);
@ -890,7 +908,7 @@ int handleShow (std::string& outs)
"color.sync.added color.sync.changed color.sync.rejected "
"color.undo.after confirmation curses data.location dateformat "
"dateformat.holiday dateformat.report dateformat.annotation debug "
"default.command default.priority default.project defaultwidth due "
"default.command default.due default.priority default.project defaultwidth due "
"dependency.confirmation dependency.reminder locale displayweeknumber "
"export.ical.class echo.command fontunderline gc locking monthsperline "
"nag next journal.time journal.time.start.annotation journal.info "

View file

@ -192,6 +192,13 @@ static void decorateTask (Task& task)
defaultPriority != "" &&
Att::validNameValue ("priority", "", defaultPriority))
task.set ("priority", defaultPriority);
// Override with default.due, if not specified.
std::string defaultDue = context.config.get ("default.due");
if (!task.has ("due") &&
defaultDue != "" &&
Att::validNameValue ("due", "", defaultDue))
task.set ("due", defaultDue);
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -28,7 +28,7 @@
use strict;
use warnings;
use Test::More tests => 18;
use Test::More tests => 22;
# Create the rc file.
if (open my $fh, '>', 'default.rc')
@ -36,7 +36,8 @@ if (open my $fh, '>', 'default.rc')
print $fh "data.location=.\n",
"default.command=list\n",
"default.project=PROJECT\n",
"default.priority=M\n";
"default.priority=M\n",
"default.due=eom\n";
close $fh;
ok (-r 'default.rc', 'Created default.rc');
}
@ -47,13 +48,15 @@ my $output = qx{../task rc:default.rc list};
like ($output, qr/ all defaults/, 'task added');
like ($output, qr/ PROJECT /, 'default project added');
like ($output, qr/ M /, 'default priority added');
like ($output, qr/\//, 'default due added');
unlink 'pending.data';
qx{../task rc:default.rc add project:specific priority:L all specified};
qx{../task rc:default.rc add project:specific priority:L due:eoy all specified};
$output = qx{../task rc:default.rc list};
like ($output, qr/ all specified/, 'task added');
like ($output, qr/ specific /, 'project specified');
like ($output, qr/ L /, 'priority specified');
like ($output, qr/\//, 'due specified');
unlink 'pending.data';
qx{../task rc:default.rc add project:specific project specified};
@ -61,6 +64,7 @@ $output = qx{../task rc:default.rc list};
like ($output, qr/ project specified/, 'task added');
like ($output, qr/ specific /, 'project specified');
like ($output, qr/ M /, 'default priority added');
like ($output, qr/\//, 'default due added');
unlink 'pending.data';
qx{../task rc:default.rc add priority:L priority specified};
@ -68,6 +72,7 @@ $output = qx{../task rc:default.rc list};
like ($output, qr/ priority specified/, 'task added');
like ($output, qr/ PROJECT /, 'default project added');
like ($output, qr/ L /, 'priority specified');
like ($output, qr/\//, 'default due added');
$output = qx{../task rc:default.rc};
like ($output, qr/1 PROJECT L .+ priority specified/, 'default command worked');