App-lens
view release on metacpan or search on metacpan
script/lens view on Meta::CPAN
# transform_FOO accepts numbers in @_
# transform0_FOO accept the whole raw \e[...m sequence
sub transform0_codes {
my $seq = shift;
$seq =~ s/\e/\\e/g;
$seq;
}
sub transform_bold {
if ($_[0] == 1) {
return @_;
} else {
return (1, @_);
}
}
sub transform_inverse {
if ($_[0] == 7) {
return ();
script/lens view on Meta::CPAN
# bright ansi fg
return (1,37);
} elsif ($_[0] >= 100 && $_[0] <= 107) {
# bright ansi bg
return (1,47);
} else {
return @_;
}
}
sub transform_nobold {
if ($_[0] == 1) {
return ();
} else {
return @_;
}
}
sub transform_noop { @_ }
sub transform_pastel {
script/lens view on Meta::CPAN
}
if (!@ARGV || (grep {$_ eq '--help'} @ARGV)) {
print <<'EOF';
lens - Transform colors in terminal output
Usage:
% command-that-produces-colored-output | lens <transform-name> [transform-option]...
List of available transforms:
bold - Set bold to all colors
mono - replace all colors with gray
nobold - remove bold
noop - do no transform
pastel - pastelize colors
ct - Use a ColorTransform::* module
Some examples:
# Make ls output mono
% ls -l --color | lens mono
# Make the WWW color swatch into monotone (green)
script/lens view on Meta::CPAN
=head1 SYNOPSIS
Usage:
% command-that-produces-colored-output | lens <transform-name>
Available transforms:
=over
=item * bold
Give bold to all colors.
=item * inverse
Inverse all colors.
=item * mono
Replace all colors with gray.
=item * nobold
Remove bold.
=item * noop
Do no transform.
=item * pastel
Pastelize colors.
=item * ct
( run in 2.496 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )