mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Custom Reports - usage
- Added defined custom reports to the usage text. This includes the new "report.X.description" configuration variable.
This commit is contained in:
parent
1f45e47e36
commit
2d07b08260
5 changed files with 84 additions and 30 deletions
|
@ -43,25 +43,27 @@
|
|||
|
||||
<p>
|
||||
More importantly, you can define your own. Here are the
|
||||
two necessary items in the .taskrc file that define a new
|
||||
three necessary items in the .taskrc file that define a new
|
||||
report:
|
||||
</p>
|
||||
|
||||
<code><pre>report.mine.columns=id,project,priority,description
|
||||
<code><pre>report.mine.description=Just the essentials
|
||||
report.mine.columns=id,project,priority,description
|
||||
report.mine.sort=priority-,project+</pre></code>
|
||||
|
||||
<p>
|
||||
This defines a report, called "mine", that has four columns:
|
||||
id, project, priority and description. It will be sorted on
|
||||
two columns: by descending priority then ascending project.
|
||||
Because this report is called "mine", it can be run with the
|
||||
command:
|
||||
The description that shows up in the task command usage page
|
||||
is "Just the essentials". Because this report is called
|
||||
"mine", it can be run with the command:
|
||||
</p>
|
||||
|
||||
<code><pre>% task mine</pre></code>
|
||||
|
||||
<p>
|
||||
A filter can also be specified like this:
|
||||
An optional filter can also be specified like this:
|
||||
</p>
|
||||
|
||||
<code><pre>report.mine.filter=priority:H +bug</pre></code>
|
||||
|
|
|
@ -164,7 +164,6 @@ void guess (const std::string& type, const char** list, std::string& candidate)
|
|||
candidate = matches[0];
|
||||
|
||||
else if (0 == matches.size ())
|
||||
// throw std::string ("Unrecognized ") + type + " '" + candidate + "'";
|
||||
candidate = "";
|
||||
|
||||
else
|
||||
|
@ -535,4 +534,10 @@ bool isCustomReport (const std::string& report)
|
|||
return false;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void allCustomReports (std::vector <std::string>& all)
|
||||
{
|
||||
all = customReports;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
38
src/task.cpp
38
src/task.cpp
|
@ -82,18 +82,6 @@ static void shortUsage (Config& conf)
|
|||
table.addCell (row, 1, "task add [tags] [attrs] desc...");
|
||||
table.addCell (row, 2, "Adds a new task");
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 1, "task list [tags] [attrs] desc...");
|
||||
table.addCell (row, 2, "Lists all tasks matching the specified criteria");
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 1, "task long [tags] [attrs] desc...");
|
||||
table.addCell (row, 2, "Lists all task, all data, matching the specified criteria");
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 1, "task ls [tags] [attrs] desc...");
|
||||
table.addCell (row, 2, "Minimal listing of all tasks matching the specified criteria");
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 1, "task completed [tags] [attrs] desc...");
|
||||
table.addCell (row, 2, "Chronological listing of all completed tasks matching the specified criteria");
|
||||
|
@ -198,6 +186,20 @@ static void shortUsage (Config& conf)
|
|||
table.addCell (row, 1, "task help");
|
||||
table.addCell (row, 2, "Shows the long usage text");
|
||||
|
||||
// Add custom reports here...
|
||||
std::vector <std::string> all;
|
||||
allCustomReports (all);
|
||||
foreach (report, all)
|
||||
{
|
||||
std::string command = std::string ("task ") + *report + std::string (" [tags] [attrs] desc...");
|
||||
std::string description = conf.get (
|
||||
std::string ("report.") + *report + ".description", std::string ("(missing description)"));
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 1, command);
|
||||
table.addCell (row, 2, description);
|
||||
}
|
||||
|
||||
std::cout << table.render ()
|
||||
<< std::endl
|
||||
<< "See http://www.beckingham.net/task.html for the latest releases and a full tutorial."
|
||||
|
@ -269,9 +271,6 @@ void loadConfFile (int argc, char** argv, Config& conf)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
// TODO Find out what this is, and either promote it to live code, or remove it.
|
||||
// std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
|
||||
|
||||
// Set up randomness.
|
||||
#ifdef HAVE_SRANDOM
|
||||
srandom (time (NULL));
|
||||
|
@ -383,15 +382,6 @@ void nag (TDB& tdb, T& task, Config& conf)
|
|||
}
|
||||
|
||||
// General form is "if there are no more deserving tasks", suppress the nag.
|
||||
/*
|
||||
std::cout << "# task.isOverdue = " << (isOverdue ? "true" : "false") << std::endl;
|
||||
std::cout << "# task.pri = " << pri << std::endl;
|
||||
std::cout << "# task.overdue = " << overdue << std::endl;
|
||||
std::cout << "# pending.high = " << high << std::endl;
|
||||
std::cout << "# pending.medium = " << medium << std::endl;
|
||||
std::cout << "# pending.low = " << low << std::endl;
|
||||
*/
|
||||
|
||||
if (isOverdue ) return;
|
||||
if (pri == 'H' && !overdue ) return;
|
||||
if (pri == 'M' && !overdue && !high ) return;
|
||||
|
|
|
@ -59,6 +59,7 @@ bool validPriority (const std::string&);
|
|||
bool validDate (std::string&, Config&);
|
||||
void loadCustomReports (Config&);
|
||||
bool isCustomReport (const std::string&);
|
||||
void allCustomReports (std::vector <std::string>&);
|
||||
|
||||
// task.cpp
|
||||
void gatherNextTasks (const TDB&, T&, Config&, std::vector <T>&, std::vector <int>&);
|
||||
|
|
56
src/tests/custom.t
Executable file
56
src/tests/custom.t
Executable file
|
@ -0,0 +1,56 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2009, 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 => 4;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'custom.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"report.foo.description=DESC\n",
|
||||
"report.foo.columns=id,description\n",
|
||||
"report.foo.sort=id+\n";
|
||||
close $fh;
|
||||
ok (-r 'custom.rc', 'Created custom.rc');
|
||||
}
|
||||
|
||||
# Generate the usage screen, and locate the custom report on it.
|
||||
my $output = qx{../task rc:custom.rc usage};
|
||||
like ($output, qr/task foo \[tags\] \[attrs\] desc\.\.\.\s+DESC\n/m, 'report.foo');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'custom.rc';
|
||||
ok (!-r 'custom.rc', 'Removed custom.rc');
|
||||
|
||||
exit 0;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue