Test
#~ @ARGV = qw[];
#~ @ARGV = qw[-json];
#~ @ARGV = qw[-h];
#
my $raw = 0;
sub _echo ($insult) {
$raw && eval 'require JSON::Tiny' ? JSON::Tiny::encode_json( {%$insult} ) : $insult;
}
GetOptio
ns( \my %h, 'help' => sub { pod2usage( -exitval => 1 ) }, 'json!' => \$raw );
my $shade = Acme::Insult::Pirate::insult(%h);
exit !( $shade ? say _echo($shade) : !say( $raw ? 'null' : '' ) );
__END__
l_insult -json # insult someone if you're a robot
evil_insult -help # get help
=head1 OPTIONS
-json Echo raw JSON encoded
package Acme::Insult::Pirate 1.1 {
use v5.38;
use HTTP::Tiny;
#~ use JSON::Tiny qw[decode_json]; # Not needed here (yet)
use URI;
use parent 'Exporter';
our %EXPORT_TAGS = ( a
state $http
//= HTTP::Tiny->new( default_headers => { Accept => 'application/json' }, agent => sprintf '%s/%.2f ', __PACKAGE__, our $VERSION );
state $api //= URI->new('ht
not found but we'll at least know when we have valid JSON
# This API only returns strings for now
#~ $res->{success} ? decode_json( $res->{content} ) : ();
$res->{success} ? {