blib/script/glax_insult.pl untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 45 CC 2 SCAR 11.0
CC
2
Cov
0%
_echo
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.0
1 use lib '../lib';
2 use v5.36;
3 use Acme::Insult::Glax;
4 use Getopt::Long;
5 use Pod::Usage;
6 use open qw[:std :encoding(UTF-8)];
7  
8 # Test
9 #~ @ARGV = qw[];
10 #~ @ARGV = qw[-j];
11 #~ @ARGV = qw[-who Tim];
12 #~ @ARGV = ( qw[-plural -who], 'Tim and John' );
13 #~ @ARGV = (qw[-adjective -sfw]);
14 #~ @ARGV = (qw[-sfw]);
15 #~ @ARGV = qw[-h];
16 #
17 my $raw = 0;
18  
19 sub _echo ($insult) { # JSON::Tiny is loaded in Acme::Insult::Glax anyway
20 $raw ? JSON::Tiny::encode_json( {%$insult} ) : $insult;
21 }
22 GetOptions( \my %h, 'who=s', 'template=s', 'plural!', 'help' => sub { pod2usage( -exitval => 1 ) }, 'json!' => \$raw, 'adjective!', 'sfw!' );
23 $h{lang} = 'en_corporate' if delete $h{sfw};
24 my $shade = delete $h{adjective} ? Acme::Insult::Glax::adjective( $h{lang} ) : Acme::Insult::Glax::insult(%h);
25 exit !( $shade ? say _echo($shade) : !say( $raw ? 'null' : '' ) );
26 __END__