| 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__ |