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
|
+ Fixed bug that added an extra line between header and graph in the
|
||||||
ghistory report.
|
ghistory report.
|
||||||
+ Added simple 'taskprogram' mailing list subscribe form to the web site.
|
+ 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 ------------------------------
|
------ old releases ------------------------------
|
||||||
|
|
||||||
|
|
|
@ -294,16 +294,24 @@ ID Project Pri Description
|
||||||
12 Errand L Remember to deposit bonus check
|
12 Errand L Remember to deposit bonus check
|
||||||
...</code></pre>
|
...</code></pre>
|
||||||
|
|
||||||
<strong>% task oldest</strong>
|
<strong>% task oldest [limit]</strong>
|
||||||
<p>
|
<p>
|
||||||
Lists the oldest tasks. Shows 10 tasks by default, but can be
|
Lists the oldest tasks. The number of tasks shown is set by
|
||||||
set via the "oldest" configuration variable.
|
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>
|
</p>
|
||||||
|
|
||||||
<strong>% task newest</strong>
|
<strong>% task newest [limit]</strong>
|
||||||
<p>
|
<p>
|
||||||
Lists the newest tasks. Shows 10 tasks by default, but can be
|
Lists the newest tasks. The number of tasks shown is set by
|
||||||
set via the "newest" configuration variable.
|
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>
|
</p>
|
||||||
|
|
||||||
<strong>% task <id> /from/to/</strong>
|
<strong>% task <id> /from/to/</strong>
|
||||||
|
|
|
@ -159,6 +159,9 @@
|
||||||
<li>Fixed bug that added an extra line between header and graph in the
|
<li>Fixed bug that added an extra line between header and graph in the
|
||||||
ghistory report.
|
ghistory report.
|
||||||
<li>Added simple 'taskprogram' mailing list subscribe form to the web site.
|
<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>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<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);
|
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;
|
std::stringstream out;
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
out << optionalBlankLine (conf)
|
out << optionalBlankLine (conf)
|
||||||
|
|
|
@ -133,7 +133,7 @@ static std::string shortUsage (Config& conf)
|
||||||
table.addCell (row, 2, "Removes the 'start' time from a task");
|
table.addCell (row, 2, "Removes the 'start' time from a task");
|
||||||
|
|
||||||
row = table.addRow ();
|
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");
|
table.addCell (row, 2, "Marks the specified task as completed");
|
||||||
|
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More tests => 33;
|
use Test::More tests => 55;
|
||||||
|
|
||||||
# Create the rc file.
|
# Create the rc file.
|
||||||
if (open my $fh, '>', 'oldest.rc')
|
if (open my $fh, '>', 'oldest.rc')
|
||||||
|
@ -78,6 +78,19 @@ like ($output, qr/nine/, 'oldest: nine');
|
||||||
like ($output, qr/ten/, 'oldest: ten');
|
like ($output, qr/ten/, 'oldest: ten');
|
||||||
unlike ($output, qr/eleven/, 'no: eleven');
|
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};
|
$output = qx{../task rc:oldest.rc newest};
|
||||||
unlike ($output, qr/one/, 'no: one');
|
unlike ($output, qr/one/, 'no: one');
|
||||||
like ($output, qr/two/, 'newest: two');
|
like ($output, qr/two/, 'newest: two');
|
||||||
|
@ -91,6 +104,19 @@ like ($output, qr/nine/, 'newest: nine');
|
||||||
like ($output, qr/ten/, 'newest: ten');
|
like ($output, qr/ten/, 'newest: ten');
|
||||||
like ($output, qr/eleven/, 'newest: eleven');
|
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.
|
# Cleanup.
|
||||||
unlink 'pending.data';
|
unlink 'pending.data';
|
||||||
ok (!-r 'pending.data', 'Removed pending.data');
|
ok (!-r 'pending.data', 'Removed pending.data');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue