diff --git a/html/custom.html b/html/custom.html index 8b202f5c1..a4a64c803 100644 --- a/html/custom.html +++ b/html/custom.html @@ -43,25 +43,27 @@

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:

-
report.mine.columns=id,project,priority,description
+                
report.mine.description=Just the essentials
+report.mine.columns=id,project,priority,description
 report.mine.sort=priority-,project+

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:

% task mine

- A filter can also be specified like this: + An optional filter can also be specified like this:

report.mine.filter=priority:H +bug
diff --git a/src/parse.cpp b/src/parse.cpp index d6528436c..b87ce8dc9 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -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 & all) +{ + all = customReports; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/task.cpp b/src/task.cpp index 00b21d9cb..3c1b2f629 100644 --- a/src/task.cpp +++ b/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 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; diff --git a/src/task.h b/src/task.h index 925b75811..dffc3ef17 100644 --- a/src/task.h +++ b/src/task.h @@ -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 &); // task.cpp void gatherNextTasks (const TDB&, T&, Config&, std::vector &, std::vector &); diff --git a/src/tests/custom.t b/src/tests/custom.t new file mode 100755 index 000000000..193e9711e --- /dev/null +++ b/src/tests/custom.t @@ -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; +