#!/usr/bin/perl
# vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2:
use strict;
use warnings FATAL => 'all';
use vars     qw($VERSION);
use autodie  qw(:all);

my $APP  = 'knnp';
$VERSION = '0.002';

use lib '../lib';

use Pod::Usage;
use Getopt::Long;
use Term::ExtendedColor        qw(fg bold);
use Term::ExtendedColor::Dzen  qw(fgd);
use Music::KNRadio::NowPlaying qw(knnp);


my $np = knnp();

$ARGV[0] = '-c' unless @ARGV;

GetOptions(
  'd|dzen'    => \&np_dzen,
  'c|color'   => \&np_256,
  'p|plain'   => \&np,
  'v|version' => \&version,
  'h|help'    => sub { pod2usage(verbose => 1); exit },
);


sub np_dzen {
  printf "%s by %s\n",
    fgd("f8a61e", $np->{artist}),
    fgd("a5f81e", $np->{title});
}

sub np_256 {
  printf "%s by %s\n",
    fg(208, bold($np->{artist})),
    fg(106, bold($np->{title}));
}

sub np_plain {
  printf "%s by %s\n", $np->{artist}, $np->{title};
}


sub version {
  print "$APP v$VERSION\n";
  exit;
}



__END__


=pod

=head1 NAME

knnp - Karlstad Rock 92.2 now playing

=head1 USAGE

knnp [OPTION]

=head1 OPTIONS

  -d, --dzen    generate dzen(2) output
  -c, --color   generate ecma-48 compatible color output
  -p, --plain   plain text mode output

  -h, --help    display this help and exit
  -v, --version display version 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
  http://github.com/trapd00r

=head1 CONTRIBUTORS

None required yet.

=head1 COPYRIGHT

Copyright 2019- 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<~/|http://japh.se>

L<knradio|http://knradio.se>

=cut
