#!/usr/bin/perl
# vim:ft=perl:et:
use strict;
my $APP = 'colorfg';

our $VERSION = '0.001';

use Pod::Usage;
use Getopt::Long;
use Term::ExtendedColor qw(fg);

unless(scalar(@ARGV) > 0 and $ARGV[0] =~ m/^[0-9]{1,3}$/) {
  pod2usage(verbose => 1);
  exit;
}

GetOptions(
  'help' => sub { print "$APP v$VERSION\n"; pod2usage(verbose => 1); },
  'man'  => sub { pod2usage(verbose => 2); },
);

parse_from_stdin(shift @ARGV);

sub parse_from_stdin {
  my $index = shift;
  while(<STDIN>) {
    print fg($index, $_);
  }
}


__END__


=pod

=head1 NAME

colorfg - color each line of input according to spec

=head1 USAGE

colorfg color_index [FILE..]

=head1 DESCRIPTION

B<colorfg> takes input from standard input and returns it colored
according to spec.

color_index is a number between 0-255, inclusive.

=head1 OPTIONS

    -h, --help  show the help and exit
    -m, --man   show the documentation and exit

=head1 REPORTING BUGS

Report bugs and/or feature requests on rt.cpan.org, the repository issue tracker
or directly to L<m@japh.se>

=head1 AUTHOR

  Magnus Woldrich
  CPAN ID: WOLDRICH
  m@japh.se
  http://japh.se

=head1 CONTRIBUTORS

None required yet.

=head1 COPYRIGHT

Copyright 2018 B<THIS APPLICATION>s L</AUTHOR> and L</CONTRIBUTORS> as listed
above.

=head1 LICENSE

This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 SEE ALSO

L<Term::ExtendedColor>

=cut

# vim: set ts=2 et sw=2: