mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement - Custom report limit override
- If a custom report has a specified limit to the number of tasks it shows, then that limit may be overridden by specifying a new quantity on the command line. - Added unit tests to verify expected behavior. - Updated documentation to reflect new functionality. - Removed obsolete documentation references to an "oldest" and "newest" configuration variable.
This commit is contained in:
parent
72f84b3c3e
commit
1c736a319d
6 changed files with 79 additions and 29 deletions
|
@ -20,6 +20,9 @@
|
|||
+ Fixed bug that added an extra line between header and graph in the
|
||||
ghistory report.
|
||||
+ Added simple 'taskprogram' mailing list subscribe form to the web site.
|
||||
+ For custom reports that define a "limit" to the number of rows of output
|
||||
such as "oldest" and "newest", task allows an override value. For
|
||||
example "task oldest 5" will display the 5 oldest tasks.
|
||||
|
||||
------ old releases ------------------------------
|
||||
|
||||
|
|
|
@ -294,16 +294,24 @@ ID Project Pri Description
|
|||
12 Errand L Remember to deposit bonus check
|
||||
...</code></pre>
|
||||
|
||||
<strong>% task oldest</strong>
|
||||
<strong>% task oldest [limit]</strong>
|
||||
<p>
|
||||
Lists the oldest tasks. Shows 10 tasks by default, but can be
|
||||
set via the "oldest" configuration variable.
|
||||
Lists the oldest tasks. The number of tasks shown is set by
|
||||
the configuration variable:
|
||||
<pre><code>report.oldest.limit=10</code></pre>
|
||||
This value can be overridden at run time by specifying the
|
||||
number of tasks on the command line:
|
||||
<pre><code>task oldest 5</code></pre>
|
||||
</p>
|
||||
|
||||
<strong>% task newest</strong>
|
||||
<strong>% task newest [limit]</strong>
|
||||
<p>
|
||||
Lists the newest tasks. Shows 10 tasks by default, but can be
|
||||
set via the "newest" configuration variable.
|
||||
Lists the newest tasks. The number of tasks shown is set by
|
||||
the configuration variable:
|
||||
<pre><code>report.newest.limit=10</code></pre>
|
||||
This value can be overridden at run time by specifying the
|
||||
number of tasks on the command line:
|
||||
<pre><code>task newest 5</code></pre>
|
||||
</p>
|
||||
|
||||
<strong>% task <id> /from/to/</strong>
|
||||
|
|
|
@ -159,6 +159,9 @@
|
|||
<li>Fixed bug that added an extra line between header and graph in the
|
||||
ghistory report.
|
||||
<li>Added simple 'taskprogram' mailing list subscribe form to the web site.
|
||||
<li>For custom reports that define a "limit" to the number of rows of output
|
||||
such as "oldest" and "newest", task allows an override value. For
|
||||
example "task oldest 5" will display the 5 oldest tasks.
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -2521,8 +2521,18 @@ std::string handleCustomReport (
|
|||
}
|
||||
}
|
||||
|
||||
// Limit the number of rows according to the report definition.
|
||||
int maximum = conf.get (std::string ("report.") + report + ".limit", (int)0);
|
||||
|
||||
// If the custom report has a defined limit, then allow an override, which
|
||||
// will show up as a single ID sequence.
|
||||
if (conf.get (std::string ("report.") + report + ".limit", (int)0) != 0)
|
||||
{
|
||||
std::vector <int> sequence = task.getAllIds ();
|
||||
if (sequence.size () == 1)
|
||||
maximum = sequence[0];
|
||||
}
|
||||
|
||||
std::stringstream out;
|
||||
if (table.rowCount ())
|
||||
out << optionalBlankLine (conf)
|
||||
|
|
|
@ -133,7 +133,7 @@ static std::string shortUsage (Config& conf)
|
|||
table.addCell (row, 2, "Removes the 'start' time from a task");
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 1, "task done ID");
|
||||
table.addCell (row, 1, "task done ID [tags] [attrs] [desc...]");
|
||||
table.addCell (row, 2, "Marks the specified task as completed");
|
||||
|
||||
row = table.addRow ();
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 33;
|
||||
use Test::More tests => 55;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'oldest.rc')
|
||||
|
@ -66,30 +66,56 @@ qx{../task rc:oldest.rc add ten; sleep 1};
|
|||
qx{../task rc:oldest.rc add eleven};
|
||||
|
||||
$output = qx{../task rc:oldest.rc oldest};
|
||||
like ($output, qr/one/, 'oldest: one');
|
||||
like ($output, qr/two/, 'oldest: two');
|
||||
like ($output, qr/three/, 'oldest: three');
|
||||
like ($output, qr/four/, 'oldest: four');
|
||||
like ($output, qr/five/, 'oldest: five');
|
||||
like ($output, qr/six/, 'oldest: six');
|
||||
like ($output, qr/seven/, 'oldest: seven');
|
||||
like ($output, qr/eight/, 'oldest: eight');
|
||||
like ($output, qr/nine/, 'oldest: nine');
|
||||
like ($output, qr/ten/, 'oldest: ten');
|
||||
like ($output, qr/one/, 'oldest: one');
|
||||
like ($output, qr/two/, 'oldest: two');
|
||||
like ($output, qr/three/, 'oldest: three');
|
||||
like ($output, qr/four/, 'oldest: four');
|
||||
like ($output, qr/five/, 'oldest: five');
|
||||
like ($output, qr/six/, 'oldest: six');
|
||||
like ($output, qr/seven/, 'oldest: seven');
|
||||
like ($output, qr/eight/, 'oldest: eight');
|
||||
like ($output, qr/nine/, 'oldest: nine');
|
||||
like ($output, qr/ten/, 'oldest: ten');
|
||||
unlike ($output, qr/eleven/, 'no: eleven');
|
||||
|
||||
$output = qx{../task rc:oldest.rc oldest 3};
|
||||
like ($output, qr/one/, 'oldest: one');
|
||||
like ($output, qr/two/, 'oldest: two');
|
||||
like ($output, qr/three/, 'oldest: three');
|
||||
unlike ($output, qr/four/, 'no: four');
|
||||
unlike ($output, qr/five/, 'no: five');
|
||||
unlike ($output, qr/six/, 'no: six');
|
||||
unlike ($output, qr/seven/, 'no: seven');
|
||||
unlike ($output, qr/eight/, 'no: eight');
|
||||
unlike ($output, qr/nine/, 'no: nine');
|
||||
unlike ($output, qr/ten/, 'no: ten');
|
||||
unlike ($output, qr/eleven/, 'no: eleven');
|
||||
|
||||
$output = qx{../task rc:oldest.rc newest};
|
||||
unlike ($output, qr/one/, 'no: one');
|
||||
like ($output, qr/two/, 'newest: two');
|
||||
like ($output, qr/three/, 'newest: three');
|
||||
like ($output, qr/four/, 'newest: four');
|
||||
like ($output, qr/five/, 'newest: five');
|
||||
like ($output, qr/six/, 'newest: six');
|
||||
like ($output, qr/seven/, 'newest: seven');
|
||||
like ($output, qr/eight/, 'newest: eight');
|
||||
like ($output, qr/nine/, 'newest: nine');
|
||||
like ($output, qr/ten/, 'newest: ten');
|
||||
like ($output, qr/eleven/, 'newest: eleven');
|
||||
unlike ($output, qr/one/, 'no: one');
|
||||
like ($output, qr/two/, 'newest: two');
|
||||
like ($output, qr/three/, 'newest: three');
|
||||
like ($output, qr/four/, 'newest: four');
|
||||
like ($output, qr/five/, 'newest: five');
|
||||
like ($output, qr/six/, 'newest: six');
|
||||
like ($output, qr/seven/, 'newest: seven');
|
||||
like ($output, qr/eight/, 'newest: eight');
|
||||
like ($output, qr/nine/, 'newest: nine');
|
||||
like ($output, qr/ten/, 'newest: ten');
|
||||
like ($output, qr/eleven/, 'newest: eleven');
|
||||
|
||||
$output = qx{../task rc:oldest.rc newest 3};
|
||||
unlike ($output, qr/one/, 'no: one');
|
||||
unlike ($output, qr/two/, 'no: two');
|
||||
unlike ($output, qr/three/, 'no: three');
|
||||
unlike ($output, qr/four/, 'no: four');
|
||||
unlike ($output, qr/five/, 'no: five');
|
||||
unlike ($output, qr/six/, 'no: six');
|
||||
unlike ($output, qr/seven/, 'no: seven');
|
||||
unlike ($output, qr/eight/, 'no: eight');
|
||||
like ($output, qr/nine/, 'newest: nine');
|
||||
like ($output, qr/ten/, 'newest: ten');
|
||||
like ($output, qr/eleven/, 'newest: eleven');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue