mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement
- Allow a separate color for error messages via the 'color.error' configuration variable.
This commit is contained in:
parent
eaae2d84da
commit
e1407437e0
21 changed files with 97 additions and 1 deletions
|
@ -32,6 +32,7 @@ Features
|
||||||
with 'dateformat.info'.
|
with 'dateformat.info'.
|
||||||
+ Bash script improvement (column names are now completed).
|
+ Bash script improvement (column names are now completed).
|
||||||
+ Feature #1013, output error, header, footnote and debug messages on standard error.
|
+ Feature #1013, output error, header, footnote and debug messages on standard error.
|
||||||
|
+ Color error messages with a specific configuration variable 'color.error'.
|
||||||
|
|
||||||
Bugs
|
Bugs
|
||||||
+ Applied patch for bug #919, so the holidays listed on the 'calendar' report
|
+ Applied patch for bug #919, so the holidays listed on the 'calendar' report
|
||||||
|
|
|
@ -1283,6 +1283,8 @@ color.due red
|
||||||
.br
|
.br
|
||||||
color.due.today red
|
color.due.today red
|
||||||
.br
|
.br
|
||||||
|
color.error yellow
|
||||||
|
.br
|
||||||
color.footnote yellow
|
color.footnote yellow
|
||||||
.br
|
.br
|
||||||
color.header yellow
|
color.header yellow
|
||||||
|
|
|
@ -812,6 +812,11 @@ Colors any task assigned to project X.
|
||||||
Colors any task where the description or any annotation contains X.
|
Colors any task where the description or any annotation contains X.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B color.error=green
|
||||||
|
Colors any of the error messages.
|
||||||
|
.RE
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B color.header=green
|
.B color.header=green
|
||||||
Colors any of the messages printed prior to the report output.
|
Colors any of the messages printed prior to the report output.
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=yellow
|
color.header=yellow
|
||||||
color.footnote=yellow
|
color.footnote=yellow
|
||||||
|
color.error=yellow
|
||||||
color.debug=yellow
|
color.debug=yellow
|
||||||
|
|
||||||
color.summary.bar=black on green
|
color.summary.bar=black on green
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=color3
|
color.header=color3
|
||||||
color.footnote=color3
|
color.footnote=color3
|
||||||
|
color.error=color3
|
||||||
color.debug=color3
|
color.debug=color3
|
||||||
|
|
||||||
color.summary.bar=black on rgb141
|
color.summary.bar=black on rgb141
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=rgb013
|
color.header=rgb013
|
||||||
color.footnote=rgb013
|
color.footnote=rgb013
|
||||||
|
color.error=rgb013
|
||||||
color.debug=rgb013
|
color.debug=rgb013
|
||||||
|
|
||||||
color.summary.bar=white on rgb003
|
color.summary.bar=white on rgb003
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=color8
|
color.header=color8
|
||||||
color.footnote=color8
|
color.footnote=color8
|
||||||
|
color.error=color8
|
||||||
color.debug=color8
|
color.debug=color8
|
||||||
|
|
||||||
color.summary.bar=black on gray12
|
color.summary.bar=black on gray12
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=rgb031
|
color.header=rgb031
|
||||||
color.footnote=rgb031
|
color.footnote=rgb031
|
||||||
|
color.error=rgb031
|
||||||
color.debug=rgb031
|
color.debug=rgb031
|
||||||
|
|
||||||
color.summary.bar=white on rgb030
|
color.summary.bar=white on rgb030
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=rgb100
|
color.header=rgb100
|
||||||
color.footnote=rgb100
|
color.footnote=rgb100
|
||||||
|
color.error=rgb100
|
||||||
color.debug=rgb100
|
color.debug=rgb100
|
||||||
|
|
||||||
color.summary.bar=white on rgb300
|
color.summary.bar=white on rgb300
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=rgb013
|
color.header=rgb013
|
||||||
color.footnote=rgb013
|
color.footnote=rgb013
|
||||||
|
color.error=rgb013
|
||||||
color.debug=rgb013
|
color.debug=rgb013
|
||||||
|
|
||||||
color.summary.bar=white on rgb103
|
color.summary.bar=white on rgb103
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=rgb031
|
color.header=rgb031
|
||||||
color.footnote=rgb031
|
color.footnote=rgb031
|
||||||
|
color.error=rgb031
|
||||||
color.debug=rgb031
|
color.debug=rgb031
|
||||||
|
|
||||||
color.summary.bar=white on rgb030
|
color.summary.bar=white on rgb030
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=blue
|
color.header=blue
|
||||||
color.footnote=blue
|
color.footnote=blue
|
||||||
|
color.error=blue
|
||||||
color.debug=blue
|
color.debug=blue
|
||||||
|
|
||||||
color.summary.bar=black on green
|
color.summary.bar=black on green
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
color=on
|
color=on
|
||||||
color.header=color4
|
color.header=color4
|
||||||
color.footnote=color4
|
color.footnote=color4
|
||||||
|
color.error=color4
|
||||||
color.debug=color4
|
color.debug=color4
|
||||||
|
|
||||||
color.summary.bar=black on rgb141
|
color.summary.bar=black on rgb141
|
||||||
|
|
|
@ -60,6 +60,7 @@ color.calendar.today=color0 on color4
|
||||||
color.calendar.weekend=on color0
|
color.calendar.weekend=on color0
|
||||||
color.calendar.weeknumber=color4
|
color.calendar.weeknumber=color4
|
||||||
|
|
||||||
|
color.error=color6
|
||||||
color.debug=color6
|
color.debug=color6
|
||||||
color.due=color9
|
color.due=color9
|
||||||
color.due.today=color1
|
color.due.today=color1
|
||||||
|
|
|
@ -60,6 +60,7 @@ color.calendar.today=color7 on color4
|
||||||
color.calendar.weekend=on color7
|
color.calendar.weekend=on color7
|
||||||
color.calendar.weeknumber=color14
|
color.calendar.weeknumber=color14
|
||||||
|
|
||||||
|
color.error=color2
|
||||||
color.debug=color3
|
color.debug=color3
|
||||||
color.due=color9
|
color.due=color9
|
||||||
color.due.today=color1
|
color.due.today=color1
|
||||||
|
|
|
@ -159,6 +159,7 @@ std::string Config::_defaults =
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
"color.header=color3 # Color of header messages\n"
|
"color.header=color3 # Color of header messages\n"
|
||||||
"color.footnote=color3 # Color of footnote messages\n"
|
"color.footnote=color3 # Color of footnote messages\n"
|
||||||
|
"color.error=color3 # Color of error messages\n"
|
||||||
"color.debug=color3 # Color of diagnostic output\n"
|
"color.debug=color3 # Color of diagnostic output\n"
|
||||||
"color.alternate=on color233 # Alternate color for line coloring\n"
|
"color.alternate=on color233 # Alternate color for line coloring\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -211,6 +212,7 @@ std::string Config::_defaults =
|
||||||
#else
|
#else
|
||||||
"color.header=yellow # Color of header messages\n"
|
"color.header=yellow # Color of header messages\n"
|
||||||
"color.footnote=yellow # Color of footnote messages\n"
|
"color.footnote=yellow # Color of footnote messages\n"
|
||||||
|
"color.error=yellow # Color of error messages\n"
|
||||||
"color.debug=yellow # Color of diagnostic output\n"
|
"color.debug=yellow # Color of diagnostic output\n"
|
||||||
"color.alternate= # Alternate color for line coloring\n"
|
"color.alternate= # Alternate color for line coloring\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
|
@ -345,7 +345,7 @@ int Context::run ()
|
||||||
std::vector <std::string>::iterator e;
|
std::vector <std::string>::iterator e;
|
||||||
for (e = errors.begin (); e != errors.end (); ++e)
|
for (e = errors.begin (); e != errors.end (); ++e)
|
||||||
if (color ())
|
if (color ())
|
||||||
std::cerr << colorizeFootnote (*e) << "\n";
|
std::cerr << colorizeError (*e) << "\n";
|
||||||
else
|
else
|
||||||
std::cerr << *e << "\n";
|
std::cerr << *e << "\n";
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@ int CmdShow::execute (std::string& output)
|
||||||
" color.deleted"
|
" color.deleted"
|
||||||
" color.due"
|
" color.due"
|
||||||
" color.due.today"
|
" color.due.today"
|
||||||
|
" color.error"
|
||||||
" color.footnote"
|
" color.footnote"
|
||||||
" color.header"
|
" color.header"
|
||||||
" color.history.add"
|
" color.history.add"
|
||||||
|
|
|
@ -55,6 +55,7 @@ void initializeColorRules ();
|
||||||
void autoColorize (Task&, Color&);
|
void autoColorize (Task&, Color&);
|
||||||
std::string colorizeHeader (const std::string&);
|
std::string colorizeHeader (const std::string&);
|
||||||
std::string colorizeFootnote (const std::string&);
|
std::string colorizeFootnote (const std::string&);
|
||||||
|
std::string colorizeError (const std::string&);
|
||||||
std::string colorizeDebug (const std::string&);
|
std::string colorizeDebug (const std::string&);
|
||||||
|
|
||||||
// dependency.cpp
|
// dependency.cpp
|
||||||
|
|
|
@ -356,6 +356,15 @@ std::string colorizeFootnote (const std::string& input)
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string colorizeError (const std::string& input)
|
||||||
|
{
|
||||||
|
if (gsColor["color.error"].nontrivial ())
|
||||||
|
return gsColor["color.error"].colorize (input);
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string colorizeDebug (const std::string& input)
|
std::string colorizeDebug (const std::string& input)
|
||||||
{
|
{
|
||||||
|
|
63
test/color.err.t
Executable file
63
test/color.err.t
Executable file
|
@ -0,0 +1,63 @@
|
||||||
|
#! /usr/bin/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 => 6;
|
||||||
|
|
||||||
|
# Create the rc file.
|
||||||
|
if (open my $fh, '>', 'color.rc')
|
||||||
|
{
|
||||||
|
print $fh "data.location=.\n",
|
||||||
|
"color.header=blue\n",
|
||||||
|
"color.footnote=red\n",
|
||||||
|
"color.error=yellow\n",
|
||||||
|
"color.debug=green\n",
|
||||||
|
"_forcecolor=1\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'color.rc', 'Created color.rc');
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test the errors colors
|
||||||
|
my $output = qx{../src/task rc:color.rc rc.debug:on add due:__ 2>&1 >/dev/null};
|
||||||
|
like ($output, qr/^\033\[33mThe\ date\/duration\ '__'\ was\ not\ recognized.\033\[0m$/xms, 'color.error');
|
||||||
|
like ($output, qr/^\033\[32mTimer\ Config::load\ \(color.rc\) .* \033\[0m$/xms, 'color.debug');
|
||||||
|
like ($output, qr/^\033\[34mUsing\ alternate\ .taskrc\ file\ color.rc\033\[0m$/xms, 'color.header');
|
||||||
|
like ($output, qr/^\033\[31mConfiguration\ override\ rc.debug:on\033\[0m$/xms, 'color.footnote');
|
||||||
|
|
||||||
|
# Cleanup.
|
||||||
|
unlink qw(pending.data completed.data undo.data backlog.data synch.key color.rc);
|
||||||
|
ok (! -r 'pending.data' &&
|
||||||
|
! -r 'completed.data' &&
|
||||||
|
! -r 'undo.data' &&
|
||||||
|
! -r 'backlog.data' &&
|
||||||
|
! -r 'synch.key' &&
|
||||||
|
! -r 'color.rc', 'Cleanup');
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue