- Added Feature #1061, which allows the 'columns' command to use a search
  string for the column name (thanks to Uli Martens).
This commit is contained in:
Paul Beckingham 2012-12-01 14:07:58 -05:00
parent d8579730f5
commit 12b12c3a62
8 changed files with 92 additions and 13 deletions

View file

@ -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

View file

@ -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.<uda-name>.type variable.
+ Added Feature #1124, which provides a '_show' command that displays all

1
NEWS
View file

@ -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

View file

@ -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 <filter> completed

View file

@ -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 <std::string> words = context.a3.extract_words ();
if (words.size () > 1)
throw std::string (STRING_CMD_COLUMNS_ARGS);
// Include all columns in the table.
std::vector <std::string> names;
std::map <std::string, Column*>::const_iterator col;
@ -73,15 +79,19 @@ int CmdColumns::execute (std::string& output)
std::vector <std::string>::iterator name;
for (name = names.begin (); name != names.end (); ++name)
{
const std::vector <std::string> styles = context.columns[*name]->styles ();
const std::vector <std::string> 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 <std::string> styles = context.columns[*name]->styles ();
const std::vector <std::string> 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] : "");
}
}
}

View file

@ -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."

View file

@ -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."

64
test/feature.1061.t Executable file
View file

@ -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;