diff --git a/AUTHORS b/AUTHORS index 4e1422feb..04cc47d85 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,6 +11,7 @@ contributions of the following people: Wim Schuermann (Contributing Author) Owen Clarke (Contributing Author) Louis-Claude Canon (Contributing Author) + Scott Kostyshak (Contributing Author) The following submitted code, packages or analysis, and deserve special thanks: @@ -74,7 +75,6 @@ The following submitted code, packages or analysis, and deserve special thanks: Oleksii Tsai Jörg Plate Markus Kuhn - Scott Kostyshak Erik Wenzel Štěpán Henek Fidel Mato diff --git a/ChangeLog b/ChangeLog index 9ded450f7..54e8e2af5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ Features (thanks to Michelle Crane). + Added Feature #953, which includes the total number of blocked and blocking tasks to the 'statistics' command output (thanks to T. Charles Yun). + + Added Feature #1061, which allows the 'columns' command to use a search + string for the column name (thanks to Uli Martens). + Added Feature #1069, which gives a clearer error when a UDA is added without the uda..type variable. + Added Feature #1124, which provides a '_show' command that displays all diff --git a/NEWS b/NEWS index 8c498c9ff..7dfdd8b47 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ New Features in taskwarrior 2.2.0 - Tasks now have a 'modified' attribute, which indicates the last time, if at all, that they were modified. - Statistics now report total number of blocked and blocking tasks. + - The 'columns' command now supports search term for the column name. New commands in taskwarrior 2.2.0 diff --git a/doc/man/task.1.in b/doc/man/task.1.in index 2cbf974f7..013a88f0f 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -155,9 +155,10 @@ Displays all possible colors, a named sample, or a legend containing all currently defined colors. .TP -.B task columns +.B task columns [substring] Displays all supported columns and formatting styles. Useful when creating -custom reports. +custom reports. If a substring is provided, only matching column names are +shown. .TP .B task completed diff --git a/src/commands/CmdColumns.cpp b/src/commands/CmdColumns.cpp index c6d203281..3eb12724b 100644 --- a/src/commands/CmdColumns.cpp +++ b/src/commands/CmdColumns.cpp @@ -42,7 +42,7 @@ extern Context context; CmdColumns::CmdColumns () { _keyword = "columns"; - _usage = "task columns"; + _usage = "task columns [substring]"; _description = STRING_CMD_COLUMNS_USAGE; _read_only = true; _displays_id = false; @@ -51,6 +51,12 @@ CmdColumns::CmdColumns () //////////////////////////////////////////////////////////////////////////////// int CmdColumns::execute (std::string& output) { + // Obtain the arguments from the description. That way, things like '--' + // have already been handled. + std::vector words = context.a3.extract_words (); + if (words.size () > 1) + throw std::string (STRING_CMD_COLUMNS_ARGS); + // Include all columns in the table. std::vector names; std::map ::const_iterator col; @@ -73,15 +79,19 @@ int CmdColumns::execute (std::string& output) std::vector ::iterator name; for (name = names.begin (); name != names.end (); ++name) { - const std::vector styles = context.columns[*name]->styles (); - const std::vector examples = context.columns[*name]->examples (); - - for (unsigned int i = 0; i < styles.size (); ++i) + if (words.size () == 0 || + find (*name, words[0], false) != std::string::npos) { - int row = formats.addRow (); - formats.set (row, 0, i == 0 ? *name : ""); - formats.set (row, 1, styles[i] + (i == 0 ? "*" : "")); - formats.set (row, 2, i < examples.size () ? examples[i] : ""); + const std::vector styles = context.columns[*name]->styles (); + const std::vector examples = context.columns[*name]->examples (); + + for (unsigned int i = 0; i < styles.size (); ++i) + { + int row = formats.addRow (); + formats.set (row, 0, i == 0 ? *name : ""); + formats.set (row, 1, styles[i] + (i == 0 ? "*" : "")); + formats.set (row, 2, i < examples.size () ? examples[i] : ""); + } } } diff --git a/src/en-US.h b/src/en-US.h index ce24810d4..ff32cd42b 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -388,6 +388,7 @@ #define STRING_CMD_COLUMNS_USAGE "All supported columns and formatting styles" #define STRING_CMD_COLUMNS_NOTE "* Means default format, and therefore optional. For example, 'due' and 'due.formatted' are equivalent." #define STRING_CMD_COLUMNS_USAGE2 "Displays only a list of supported columns" +#define STRING_CMD_COLUMNS_ARGS "You can only specify one search string." #define STRING_CMD_DENO_USAGE "Deletes an annotation" #define STRING_CMD_DENO_WORDS "An annotation pattern must be provided." diff --git a/src/es-ES.h b/src/es-ES.h index 41c3014f8..b5587a291 100644 --- a/src/es-ES.h +++ b/src/es-ES.h @@ -398,8 +398,8 @@ #define STRING_CMD_COLUMNS_USAGE "Todas las columnas y estilos de formato soportados" #define STRING_CMD_COLUMNS_NOTE "* Significa formato por defecto, y por lo tanto opcional. Por ejemplo 'due' y 'due.formatted' son equivalentes." - #define STRING_CMD_COLUMNS_USAGE2 "Muestra una lista de columnas (solo nombres) soportadas" +#define STRING_CMD_COLUMNS_ARGS "Solo puede especificar un término de búsqueda." #define STRING_CMD_DENO_USAGE "Elimina una anotación" #define STRING_CMD_DENO_WORDS "Se debe proporcionar un patrón de anotación." diff --git a/test/feature.1061.t b/test/feature.1061.t new file mode 100755 index 000000000..79f691133 --- /dev/null +++ b/test/feature.1061.t @@ -0,0 +1,64 @@ +#! /usr/bin/env perl +################################################################################ +## taskwarrior - a command line task list manager. +## +## Copyright 2006-2012, Paul Beckingham, Federico Hernandez. +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included +## in all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. +## +## http://www.opensource.org/licenses/mit-license.php +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 8; + +# Create the rc file. +if (open my $fh, '>', 'bug.rc') +{ + print $fh "data.location=.\n", + "color=off\n"; + close $fh; + ok (-r 'bug.rc', 'Created bug.rc'); +} + +# Test: task columns +# task columns descr +my $output = qx{../src/task rc:bug.rc columns 2>/dev/null}; +like ($output, qr/description/, 'columns - found description'); +like ($output, qr/uuid/, 'columns - found uuid'); +like ($output, qr/project/, 'columns - found project'); + +$output = qx{../src/task rc:bug.rc columns escr 2>/dev/null}; +like ($output, qr/description/, 'columns - found \'escr\' in description'); +unlike ($output, qr/uuid/, 'columns - did not find \'escr\' in uuid'); +unlike ($output, qr/project/, 'columns - did not find \'escr\' in project'); + +# Cleanup. +unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc); +ok (! -r 'pending.data' && + ! -r 'completed.data' && + ! -r 'undo.data' && + ! -r 'backlog.data' && + ! -r 'synch.key' && + ! -r 'bug.rc', 'Cleanup'); + +exit 0; +