#!/usr/bin/perl

use vars qw($APP $VERSION);
$APP     = 'uncolor';
$VERSION = '0.102';

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

!@ARGV and parse_from_stdin();

GetOptions(
  # - read from STDIN
  ''     => \&parse_from_stdin,
  'help' => sub { print "$APP v$VERSION\n"; pod2usage(verbose => 1); },
  'man'  => sub { pod2usage(verbose => 2); },
);

sub parse_from_stdin {
  while(<STDIN>) {
    print uncolor($_);
  }
}

for(@ARGV) {
  -f $_ and open(my $fh, '<', $_) or die($!);
  my @content = <$fh>;

  print for uncolor(@content);
}

=pod

=head1 NAME

uncolor - strip input from attached colors and attributes

=head1 USAGE

uncolor [FILE..]

=head1 DESCRIPTION

uncolor takes input from files or standard input and returns it without colors
or attributes.

=head1 OPTIONS

     -          read from standard input
    -h, --help  show the help
    -m, --man   show the documentation

=head1 AUTHOR

Written by Magnus Woldrich

=head1 REPORTING BUGS

Report bugs to trapd00r@trapd00r.se

=head1 COPYRIGHT

Copyright (C) 2010, 2011 Magnus Woldrich

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

=cut
