mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 05:27:47 +02:00
Feature #1061
- 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:
parent
d8579730f5
commit
12b12c3a62
8 changed files with 92 additions and 13 deletions
2
AUTHORS
2
AUTHORS
|
@ -11,6 +11,7 @@ contributions of the following people:
|
||||||
Wim Schuermann (Contributing Author)
|
Wim Schuermann (Contributing Author)
|
||||||
Owen Clarke (Contributing Author)
|
Owen Clarke (Contributing Author)
|
||||||
Louis-Claude Canon (Contributing Author)
|
Louis-Claude Canon (Contributing Author)
|
||||||
|
Scott Kostyshak (Contributing Author)
|
||||||
|
|
||||||
The following submitted code, packages or analysis, and deserve special thanks:
|
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
|
Oleksii Tsai
|
||||||
Jörg Plate
|
Jörg Plate
|
||||||
Markus Kuhn
|
Markus Kuhn
|
||||||
Scott Kostyshak
|
|
||||||
Erik Wenzel
|
Erik Wenzel
|
||||||
Štěpán Henek
|
Štěpán Henek
|
||||||
Fidel Mato
|
Fidel Mato
|
||||||
|
|
|
@ -7,6 +7,8 @@ Features
|
||||||
(thanks to Michelle Crane).
|
(thanks to Michelle Crane).
|
||||||
+ Added Feature #953, which includes the total number of blocked and blocking
|
+ Added Feature #953, which includes the total number of blocked and blocking
|
||||||
tasks to the 'statistics' command output (thanks to T. Charles Yun).
|
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
|
+ Added Feature #1069, which gives a clearer error when a UDA
|
||||||
is added without the uda.<uda-name>.type variable.
|
is added without the uda.<uda-name>.type variable.
|
||||||
+ Added Feature #1124, which provides a '_show' command that displays all
|
+ Added Feature #1124, which provides a '_show' command that displays all
|
||||||
|
|
1
NEWS
1
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
|
- Tasks now have a 'modified' attribute, which indicates the last time, if at
|
||||||
all, that they were modified.
|
all, that they were modified.
|
||||||
- Statistics now report total number of blocked and blocking tasks.
|
- 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
|
New commands in taskwarrior 2.2.0
|
||||||
|
|
||||||
|
|
|
@ -155,9 +155,10 @@ Displays all possible colors, a named sample, or a legend containing all
|
||||||
currently defined colors.
|
currently defined colors.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B task columns
|
.B task columns [substring]
|
||||||
Displays all supported columns and formatting styles. Useful when creating
|
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
|
.TP
|
||||||
.B task <filter> completed
|
.B task <filter> completed
|
||||||
|
|
|
@ -42,7 +42,7 @@ extern Context context;
|
||||||
CmdColumns::CmdColumns ()
|
CmdColumns::CmdColumns ()
|
||||||
{
|
{
|
||||||
_keyword = "columns";
|
_keyword = "columns";
|
||||||
_usage = "task columns";
|
_usage = "task columns [substring]";
|
||||||
_description = STRING_CMD_COLUMNS_USAGE;
|
_description = STRING_CMD_COLUMNS_USAGE;
|
||||||
_read_only = true;
|
_read_only = true;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
|
@ -51,6 +51,12 @@ CmdColumns::CmdColumns ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdColumns::execute (std::string& output)
|
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.
|
// Include all columns in the table.
|
||||||
std::vector <std::string> names;
|
std::vector <std::string> names;
|
||||||
std::map <std::string, Column*>::const_iterator col;
|
std::map <std::string, Column*>::const_iterator col;
|
||||||
|
@ -72,6 +78,9 @@ int CmdColumns::execute (std::string& output)
|
||||||
|
|
||||||
std::vector <std::string>::iterator name;
|
std::vector <std::string>::iterator name;
|
||||||
for (name = names.begin (); name != names.end (); ++name)
|
for (name = names.begin (); name != names.end (); ++name)
|
||||||
|
{
|
||||||
|
if (words.size () == 0 ||
|
||||||
|
find (*name, words[0], false) != std::string::npos)
|
||||||
{
|
{
|
||||||
const std::vector <std::string> styles = context.columns[*name]->styles ();
|
const std::vector <std::string> styles = context.columns[*name]->styles ();
|
||||||
const std::vector <std::string> examples = context.columns[*name]->examples ();
|
const std::vector <std::string> examples = context.columns[*name]->examples ();
|
||||||
|
@ -84,6 +93,7 @@ int CmdColumns::execute (std::string& output)
|
||||||
formats.set (row, 2, i < examples.size () ? examples[i] : "");
|
formats.set (row, 2, i < examples.size () ? examples[i] : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
output = optionalBlankLine ()
|
output = optionalBlankLine ()
|
||||||
+ formats.render ()
|
+ formats.render ()
|
||||||
|
|
|
@ -388,6 +388,7 @@
|
||||||
#define STRING_CMD_COLUMNS_USAGE "All supported columns and formatting styles"
|
#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_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_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_USAGE "Deletes an annotation"
|
||||||
#define STRING_CMD_DENO_WORDS "An annotation pattern must be provided."
|
#define STRING_CMD_DENO_WORDS "An annotation pattern must be provided."
|
||||||
|
|
|
@ -398,8 +398,8 @@
|
||||||
|
|
||||||
#define STRING_CMD_COLUMNS_USAGE "Todas las columnas y estilos de formato soportados"
|
#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_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_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_USAGE "Elimina una anotación"
|
||||||
#define STRING_CMD_DENO_WORDS "Se debe proporcionar un patrón de anotación."
|
#define STRING_CMD_DENO_WORDS "Se debe proporcionar un patrón de anotación."
|
||||||
|
|
64
test/feature.1061.t
Executable file
64
test/feature.1061.t
Executable 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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue