| 1 |
#!/usr/bin/perl |
| 2 |
# vim:ft=perl:et: |
| 3 |
use strict; |
| 4 |
my $APP = 'colorfg'; |
| 5 |
|
| 6 |
our $VERSION = '0.001'; |
| 7 |
|
| 8 |
use Pod::Usage; |
| 9 |
use Getopt::Long; |
| 10 |
use Term::ExtendedColor qw(fg); |
| 11 |
|
| 12 |
unless(scalar(@ARGV) > 0 and $ARGV[0] =~ m/^[0-9]{1,3}$/) { |
| 13 |
pod2usage(verbose => 1); |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
GetOptions( |
| 18 |
'help' => sub { print "$APP v$VERSION\n"; pod2usage(verbose => 1); }, |
| 19 |
'man' => sub { pod2usage(verbose => 2); }, |
| 20 |
); |
| 21 |
|
| 22 |
parse_from_stdin(shift @ARGV); |
| 23 |
|
| 24 |
sub parse_from_stdin { |
| 25 |
my $index = shift; |
| 26 |
while(<STDIN>) { |
| 27 |
print fg($index, $_); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
__END__ |
| 33 |
|
| 34 |
|
| 35 |
=pod |
| 36 |
|
| 37 |
=head1 NAME |
| 38 |
|
| 39 |
colorfg - color each line of input according to spec |
| 40 |
|
| 41 |
=head1 USAGE |
| 42 |
|
| 43 |
colorfg color_index [FILE..] |
| 44 |
|
| 45 |
=head1 DESCRIPTION |
| 46 |
|
| 47 |
B<colorfg> takes input from standard input and returns it colored |
| 48 |
according to spec. |
| 49 |
|
| 50 |
color_index is a number between 0-255, inclusive. |
| 51 |
|
| 52 |
=head1 OPTIONS |
| 53 |
|
| 54 |
-h, --help show the help and exit |
| 55 |
-m, --man show the documentation and exit |
| 56 |
|
| 57 |
=head1 REPORTING BUGS |
| 58 |
|
| 59 |
Report bugs and/or feature requests on rt.cpan.org, the repository issue tracker |
| 60 |
or directly to L<[email protected]> |
| 61 |
|
| 62 |
=head1 AUTHOR |
| 63 |
|
| 64 |
Magnus Woldrich |
| 65 |
CPAN ID: WOLDRICH |
| 66 |
[email protected] |
| 67 |
http://japh.se |
| 68 |
|
| 69 |
=head1 CONTRIBUTORS |
| 70 |
|
| 71 |
None required yet. |
| 72 |
|
| 73 |
=head1 COPYRIGHT |
| 74 |
|
| 75 |
Copyright 2018 B<THIS APPLICATION>s L</AUTHOR> and L</CONTRIBUTORS> as listed |
| 76 |
above. |
| 77 |
|
| 78 |
=head1 LICENSE |
| 79 |
|
| 80 |
This program is free software; you can redistribute it and/or modify |
| 81 |
it under the same terms as Perl itself. |
| 82 |
|
| 83 |
=head1 SEE ALSO |
| 84 |
|
| 85 |
L<Term::ExtendedColor> |
| 86 |
|
| 87 |
=cut |
| 88 |
|
| 89 |
# vim: set ts=2 et sw=2: |