ARGV = qw[-json];
#~ @ARGV = qw[-id 5 -json];
#~ @ARGV = qw[-json -id 333];
#~ @ARGV = qw[-all -json];
#~ @ARGV = qw[-id 216];
#
my $raw = 0;
my ( $id, $all );
sub _echo ($slip) { # JSON::Tiny is
loaded in Acme::Free::Advice::Unsolicited anyway
$raw ? JSON::Tiny::encode_json($slip) : $slip;
}
GetOptions( 'json' => \$raw, 'help' => sub { pod2usage( -exitval => 1 ) }, 'id=i' => \$id, 'all!'
_kk -id 5 -json # specific advice by ID but you're a robot
advice_kk -all # get all advice
advice_kk -help # get help
=head1 OPTIONS
-json
d 1.1 { # https://kk-advice.koyeb.app/api
use v5.38;
use HTTP::Tiny;
use JSON::Tiny qw[decode_json];
use parent 'Exporter';
our %EXPORT_TAGS = ( all => [ our @EXPORT_OK = qw[adv
state $http
//= HTTP::Tiny->new( default_headers => { Accept => 'application/json' }, agent => sprintf '%s/%.2f ', __PACKAGE__, our $VERSION );
my $res = $http->get($uri);
ice is not found but we'll at least know when we have valid JSON
$res->{success} ? decode_json( $res->{content} ) : ();
}
#
sub advice ( $advice_id //= () ) {
my $res = _ht