App-highlight
view release on metacpan or search on metacpan
lib/App/highlight.pm view on Meta::CPAN
use strict;
use warnings;
package App::highlight;
{
$App::highlight::VERSION = '0.14';
}
use base 'App::Cmd::Simple';
use Try::Tiny;
use Module::Load qw(load);
use Getopt::Long::Descriptive;
my $COLOR_SUPPORT = 1;
my @COLORS;
my %COLOR_MODULES = (
'Term::ANSIColor' => [ 'color', 'colored' ],
);
# windows support
if ($^O eq 'MSWin32') {
$COLOR_MODULES{'Win32::Console::ANSI'} = [];
}
try {
for my $module (sort keys %COLOR_MODULES) {
load($module, @{ $COLOR_MODULES{$module} });
}
@COLORS = map { [ color("bold $_"), color('reset') ] } (
qw(red green yellow blue magenta cyan)
);
}
catch {
$COLOR_SUPPORT = 0;
};
my @NOCOLORS = (
[ '<<', '>>' ],
[ '[[', ']]' ],
[ '((', '))' ],
[ '{{', '}}' ],
[ '**', '**' ],
[ '__', '__' ],
);
sub opt_spec {
return (
[
one_of => [
[ 'color|c' => "use terminal color for highlighting (default)" ],
[ 'no-color|C' => "don't use terminal color" ],
],
],
[
one_of => [
[ 'escape|e' => "auto-escape input (default)" ],
[ 'no-escape|regex|n|r' => "don't auto-escape input (regex mode)" ],
]
],
[ 'ignore-case|i' => "ignore case for matches" ],
[ 'full-line|l' => "highlight the whole matched line" ],
[ 'one-color|o' => "use only one color for all matches" ],
[ 'show-bad-spaces|b' => "highlight spaces at the end of lines" ],
[ 'version|v' => "show version number" ],
[ 'help|h' => "display a usage message" ],
);
}
( run in 2.140 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )