Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1157800
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Joe Perches <joe@perches.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/3] checkpatch: colorize output to terminal |
| Date | Wed, 03 Jun 2015 18:00:02 +0200 |
| Message-ID | <pxjfc-5DK-19@gated-at.bofh.it> (permalink) |
| References | <pxjfb-5DK-1@gated-at.bofh.it> |
| X-Original-To | Andrew Morton <akpm@linux-foundation.org>, Andy Whitcroft <apw@canonical.com> |
| X-Session-Marker | 6A6F6540706572636865732E636F6D |
| X-Spam-Summary | 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:800:960:973:982:988:989:1260:1345:1359:1437:1534:1542:1711:1730:1747:1777:1792:1801:2197:2199:2393:2559:2562:3138:3139:3140:3141:3142:3354:3653:3865:3867:3868:3871:4250:4321:4605:5007:6119:6261:7875:7903:8957:9040:9121:10004:10848:11026:11233:11658:11914:12043:12291:12438:12517:12519:12555:13095:13161:13229:14394:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 |
| X-He-Tag | corn37_78521b936460c |
| X-Filterd-Recvd-Size | 3172 |
| X-Mailer | git-send-email 2.1.2 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 89 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Petr Mladek <pmladek@suse.cz>, linux-kernel@vger.kernel.org |
| X-Original-Date | Wed, 3 Jun 2015 08:53:39 -0700 |
| X-Original-Message-ID | <376fce5d30bef4610eee2f1e798e2d496fbe7848.1433346576.git.joe@perches.com> |
| X-Original-References | <cover.1433346576.git.joe@perches.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | aioe.org linux.kernel:1157800 |
Show key headers only | View raw
Add optional colors to make seeing message types a bit easier.
Add --color command line switch, default:on
Error is RED, warning is YELLOW, check is GREEN.
The message type, if shown, is BLUE.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index eaa76bd..cef2cd4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -9,6 +9,7 @@ use strict;
use POSIX;
use File::Basename;
use Cwd 'abs_path';
+use Term::ANSIColor qw(:constants);
my $P = $0;
my $D = dirname(abs_path($P));
@@ -49,6 +50,7 @@ my $min_conf_desc_length = 4;
my $spelling_file = "$D/spelling.txt";
my $codespell = 0;
my $codespellfile = "/usr/local/share/codespell/dictionary.txt";
+my $color = 1;
sub help {
my ($exitcode) = @_;
@@ -93,6 +95,7 @@ Options:
--codespell Use the codespell dictionary for spelling/typos
(default:/usr/local/share/codespell/dictionary.txt)
--codespellfile Use this codespell dictionary
+ --color Use colors when output is STDOUT (default: on)
-h, --help, --version display this help and exit
When FILE is - read standard input.
@@ -153,6 +156,7 @@ GetOptions(
'test-only=s' => \$tst_only,
'codespell!' => \$codespell,
'codespellfile=s' => \$codespellfile,
+ 'color!' => \$color,
'h|help' => \$help,
'version' => \$help
) or help(1);
@@ -1672,15 +1676,26 @@ sub report {
(defined $tst_only && $msg !~ /\Q$tst_only\E/)) {
return 0;
}
- my $line;
+ my $output = '';
+ if (-t STDOUT && $color) {
+ if ($level eq 'ERROR') {
+ $output .= RED;
+ } elsif ($level eq 'WARNING') {
+ $output .= YELLOW;
+ } else {
+ $output .= GREEN;
+ }
+ }
+ $output .= $prefix . $level . ':';
if ($show_types) {
- $line = "$prefix$level:$type: $msg\n";
- } else {
- $line = "$prefix$level: $msg\n";
+ $output .= BLUE if (-t STDOUT && $color);
+ $output .= "$type:";
}
- $line = (split('\n', $line))[0] . "\n" if ($terse);
+ $output .= RESET if (-t STDOUT && $color);
+ $output .= ' ' . $msg . "\n";
+ $output = (split('\n', $output))[0] . "\n" if ($terse);
- push(our @report, $line);
+ push(our @report, $output);
return 1;
}
--
2.1.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] checkpatch: output style changes Joe Perches <joe@perches.com> - 2015-06-03 18:00 +0200
[PATCH 2/3] checkpatch: colorize output to terminal Joe Perches <joe@perches.com> - 2015-06-03 18:00 +0200
Re: [PATCH 2/3] checkpatch: colorize output to terminal Petr Mladek <pmladek@suse.cz> - 2015-06-04 14:10 +0200
[PATCH 1/3] checkpatch: Improve output with multiple command-line files Joe Perches <joe@perches.com> - 2015-06-03 18:00 +0200
Re: [PATCH 1/3] checkpatch: Improve output with multiple command-line files Petr Mladek <pmladek@suse.cz> - 2015-06-04 14:10 +0200
Re: [PATCH 1/3] checkpatch: Improve output with multiple command-line files Joe Perches <joe@perches.com> - 2015-06-04 14:20 +0200
[PATCH 3/3] checkpatch: Add --showfile to allow input via pipe to show filenames Joe Perches <joe@perches.com> - 2015-06-03 18:00 +0200
Re: [PATCH 3/3] checkpatch: Add --showfile to allow input via pipe to show filenames Petr Mladek <pmladek@suse.cz> - 2015-06-04 14:20 +0200
csiph-web