Acme-Insult-Evil/script/evil_insult.pl
use lib '../lib';
use v5.36;
use Acme::Insult::Evil;
use Getopt::Long;
use Pod::Usage;
use open qw[:std :encoding(UTF-8)];
# Test
#~ @ARGV = qw[];
#~ @ARGV = qw[-json];
#~ @ARGV = qw[-language fr];
#~ @ARGV = qw[-h];
#
my $raw = 0;
sub _echo ($insult) { # JSON::Tiny is loaded in Acme::Free::Advice::Unsolicited anyway
$raw ? JSON::Tiny::encode_json( {%$insult} ) : $insult;
}
GetOptions( \my %h, 'language=s', 'help' => sub { pod2usage( -exitval => 1 ) }, 'json!' => \$raw );
my $shade = Acme::Insult::Evil::insult(%h);
exit !( $shade ? say _echo($shade) : !say( $raw ? 'null' : '' ) );
__END__
=head1 NAME
evil_insult - Generate evil insults on the terminal
=head1 SYNOPSIS
evil_insult # generate a random insult
evil_insult -json # insult someone if you're a robot
evil_insult -lang fr # generate an insult in French
evil_insult -help # get help
=head1 OPTIONS
-json Echo raw JSON encoded data
-lang <code> Generates an insult in a given language
-help Display this help message
=head1 DESCRIPTION
This script wraps Acme::Insult::Evil.
=head1 LICENSE & LEGAL
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License
2. Other copyrights, terms, and conditions may apply to data transmitted through this module.
Insults are generated by the L<Evil Insult Generator|https://evilinsult.com/>.
=head1 AUTHOR
Sanko Robinson E<lt>sanko@cpan.orgE<gt>
=cut