From bd0dbe3af6629e02432072b1be46a7123659b4b5 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 19 Mar 2011 01:18:56 -0400 Subject: [PATCH] Unit Tests, Documentation - Added 'ids' command to task.1.in. - Added unit test for 'ids' command. - Reformatted 'help' output for the ~ modifier. --- doc/man/task.1.in | 11 ++++++++ src/report.cpp | 6 ++-- test/ids.t | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 3 deletions(-) create mode 100755 test/ids.t diff --git a/doc/man/task.1.in b/doc/man/task.1.in index 7383c0f59..461494574 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -197,6 +197,17 @@ currently defined colors. .B count [filter] Displays only a count of tasks matching the filter. +.TP +.B ids [filter] +Applies the filter then extracts only the task IDs and presents them as +a range, for example: 1-4,12. This is useful as input to a task command, +to achieve this: + + task priority:H $(task ids project:Home) + +This example first gets the IDs for the project:Home filter, then sets +the priority to H for each of those tasks. + .TP .B version Shows the taskwarrior version number diff --git a/src/report.cpp b/src/report.cpp index a3e2784b1..f073f882f 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -346,12 +346,12 @@ int longUsage (std::string& outs) << " word" << "\n" << " noword" << "\n" << "\n" - << "Modifiers can be inverted with the ~ character:" << "\n" - << " project.~is is equivalent to project.isnt" << "\n" - << "\n" << " For example:" << "\n" << " task list due.before:eom priority.not:L" << "\n" << "\n" + << " Modifiers can be inverted with the ~ character:" << "\n" + << " project.~is is equivalent to project.isnt" << "\n" + << "\n" << "The default .taskrc file can be overridden with:" << "\n" << " task rc: ..." << "\n" << "\n" diff --git a/test/ids.t b/test/ids.t new file mode 100755 index 000000000..e53f70b88 --- /dev/null +++ b/test/ids.t @@ -0,0 +1,72 @@ +#! /usr/bin/perl +################################################################################ +## taskwarrior - a command line task list manager. +## +## Copyright 2010 - 2011, Paul Beckingham, Federico Hernandez. +## 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 => 8; + +# Create the rc file. +if (open my $fh, '>', 'ids.rc') +{ + print $fh "data.location=.\n", + "confirmation=off\n"; + close $fh; + ok (-r 'ids.rc', 'Created ids.rc'); +} + +# Test the count command. +qx{../src/task rc:ids.rc add one +A +B}; +qx{../src/task rc:ids.rc add two +A }; +qx{../src/task rc:ids.rc add three +A +B}; +qx{../src/task rc:ids.rc add four }; +qx{../src/task rc:ids.rc add five +A +B}; + +my $output = qx{../src/task rc:ids.rc ids +A}; +like ($output, qr/^1-3,5$/ms, 'ids +A --> 1-3,5'); + +$output = qx{../src/task rc:ids.rc ids +B}; +like ($output, qr/^1,3,5$/ms, 'ids +B --> 1,3,5'); + +$output = qx{../src/task rc:ids.rc ids +A -B}; +like ($output, qr/^2$/ms, 'ids +A -B --> 2'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'completed.data'; +ok (!-r 'completed.data', 'Removed completed.data'); + +unlink 'undo.data'; +ok (!-r 'undo.data', 'Removed undo.data'); + +unlink 'ids.rc'; +ok (!-r 'ids.rc', 'Removed ids.rc'); + +exit 0; +