mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Feature
- Add the configuration variable 'print.empty.columns'. - If this variable is set to 'no', columns with all empty values are not printed. This variable defaults to 'yes' (thus nothing is changed by default). - Updated taskrc.5.in to mention the new variable. - Added unit tests.
This commit is contained in:
parent
a7b20b7a4e
commit
d7c225c87b
6 changed files with 92 additions and 4 deletions
|
@ -34,6 +34,7 @@ Features
|
||||||
if a modification has occurred.
|
if a modification has occurred.
|
||||||
+ Fixed the mechanism used for selecting translations (thanks to Fidel Mato).
|
+ Fixed the mechanism used for selecting translations (thanks to Fidel Mato).
|
||||||
+ Added new export script: export-tsv.pl.
|
+ Added new export script: export-tsv.pl.
|
||||||
|
+ Added the configuration variable 'print.empty.columns'.
|
||||||
|
|
||||||
Bugs
|
Bugs
|
||||||
+ Fixed bug #947, #1031, which kept expanding aliases after the '--' operator
|
+ Fixed bug #947, #1031, which kept expanding aliases after the '--' operator
|
||||||
|
|
|
@ -346,6 +346,11 @@ May be yes or no, and determines whether the 'tags' command lists all the tag
|
||||||
names you have used, or just the ones used in active tasks. The default value is
|
names you have used, or just the ones used in active tasks. The default value is
|
||||||
"no".
|
"no".
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B print.empty.columns=yes
|
||||||
|
May be yes or no, and determines whether columns with no data for any task are
|
||||||
|
printed. Defaults to yes.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B search.case.sensitive=yes
|
.B search.case.sensitive=yes
|
||||||
May be yes or no, and determines whether keyword lookup and substitutions on the
|
May be yes or no, and determines whether keyword lookup and substitutions on the
|
||||||
|
|
|
@ -289,6 +289,7 @@ std::string Config::_defaults =
|
||||||
"complete.all.tags=no # Include old tag names in '_ags' command\n"
|
"complete.all.tags=no # Include old tag names in '_ags' command\n"
|
||||||
"list.all.projects=no # Include old project names in 'projects' command\n"
|
"list.all.projects=no # Include old project names in 'projects' command\n"
|
||||||
"list.all.tags=no # Include old tag names in 'tags' command\n"
|
"list.all.tags=no # Include old tag names in 'tags' command\n"
|
||||||
|
"print.empty.columns=yes # Print columns which have no data for any task\n"
|
||||||
"debug=no # Display diagnostics\n"
|
"debug=no # Display diagnostics\n"
|
||||||
"extensions=off # Extension system master switch\n"
|
"extensions=off # Extension system master switch\n"
|
||||||
"fontunderline=yes # Uses underlines rather than -------\n"
|
"fontunderline=yes # Uses underlines rather than -------\n"
|
||||||
|
|
|
@ -113,6 +113,9 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
||||||
{
|
{
|
||||||
context.timer_render.start ();
|
context.timer_render.start ();
|
||||||
|
|
||||||
|
bool const print_empty_columns = context.config.getBoolean ("print.empty.columns");
|
||||||
|
std::vector <Column*> nonempty_columns;
|
||||||
|
|
||||||
// Determine minimal, ideal column widths.
|
// Determine minimal, ideal column widths.
|
||||||
std::vector <int> minimal;
|
std::vector <int> minimal;
|
||||||
std::vector <int> ideal;
|
std::vector <int> ideal;
|
||||||
|
@ -121,7 +124,7 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
||||||
for (i = _columns.begin (); i != _columns.end (); ++i)
|
for (i = _columns.begin (); i != _columns.end (); ++i)
|
||||||
{
|
{
|
||||||
// Headers factor in to width calculations.
|
// Headers factor in to width calculations.
|
||||||
int global_min = utf8_length ((*i)->label ());
|
int global_min = 0;
|
||||||
int global_ideal = global_min;
|
int global_ideal = global_min;
|
||||||
|
|
||||||
for (unsigned int s = 0; s < sequence.size (); ++s)
|
for (unsigned int s = 0; s < sequence.size (); ++s)
|
||||||
|
@ -141,10 +144,24 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
||||||
if (ideal > global_ideal) global_ideal = ideal;
|
if (ideal > global_ideal) global_ideal = ideal;
|
||||||
}
|
}
|
||||||
|
|
||||||
minimal.push_back (global_min);
|
if (print_empty_columns || global_min != 0)
|
||||||
ideal.push_back (global_ideal);
|
{
|
||||||
|
int label_length = utf8_length ((*i)->label ());
|
||||||
|
if (label_length > global_min) global_min = label_length;
|
||||||
|
if (label_length > global_ideal) global_ideal = label_length;
|
||||||
|
minimal.push_back (global_min);
|
||||||
|
ideal.push_back (global_ideal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!print_empty_columns && global_min != 0)
|
||||||
|
{
|
||||||
|
nonempty_columns.push_back(*i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!print_empty_columns)
|
||||||
|
_columns = nonempty_columns;
|
||||||
|
|
||||||
// Sum the minimal widths.
|
// Sum the minimal widths.
|
||||||
int sum_minimal = 0;
|
int sum_minimal = 0;
|
||||||
std::vector <int>::iterator c;
|
std::vector <int>::iterator c;
|
||||||
|
|
|
@ -85,7 +85,11 @@ void ColumnPriority::measure (Task& task, int& minimum, int& maximum)
|
||||||
{
|
{
|
||||||
std::string priority = task.get (_name);
|
std::string priority = task.get (_name);
|
||||||
|
|
||||||
minimum = maximum = 1;
|
if (priority == "")
|
||||||
|
minimum = maximum = 0;
|
||||||
|
else
|
||||||
|
minimum = maximum = 1;
|
||||||
|
|
||||||
if (_style == "long")
|
if (_style == "long")
|
||||||
{
|
{
|
||||||
if (priority == "H") minimum = maximum = 4;
|
if (priority == "H") minimum = maximum = 4;
|
||||||
|
|
60
test/feature.print.empty.columns.t
Executable file
60
test/feature.print.empty.columns.t
Executable file
|
@ -0,0 +1,60 @@
|
||||||
|
#! /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 => 4;
|
||||||
|
|
||||||
|
# Create the rc file.
|
||||||
|
if (open my $fh, '>', 'bug.rc')
|
||||||
|
{
|
||||||
|
print $fh "data.location=.\n";
|
||||||
|
print $fh "report.test.columns=id,project\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'bug.rc', 'Created bug.rc');
|
||||||
|
}
|
||||||
|
|
||||||
|
# Feature: variable to control printing of empty columns
|
||||||
|
qx{../src/task rc:bug.rc add sample desc 2>&1};
|
||||||
|
|
||||||
|
my $output = qx{../src/task test rc:bug.rc 2>&1};
|
||||||
|
like ($output, qr/Project/, 'empty \'project\' column is printed by default');
|
||||||
|
|
||||||
|
$output = qx{../src/task test rc.print.empty.columns:no rc:bug.rc 2>&1};
|
||||||
|
unlike ($output, qr/Project/, 'empty \'project\' column is not printed if rc.print.empty.columns:no');
|
||||||
|
|
||||||
|
# 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