Acme-Free-Advice

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

[![Actions Status](https://github.com/sanko/Acme-Free-Advice/actions/workflows/ci.yml/badge.svg)](https://github.com/sanko/Acme-Free-Advice/actions) [![MetaCPAN Release](https://badge.fury.io/pl/Acme-Free-Advice.svg)](https://metacpan.org/release/Acm...
# NAME

Acme::Free::Advice - Wise words. Dumb code.

# SYNOPSIS

```perl
use Acme::Free::Advice qw[advice];
say advice;
```

# DESCRIPTION

Acme::Free::Advice spits out advice. Good advice. Bad advice. Advice. It's a fortune cookie.

# METHODS

These functions may be imported by name or with the `:all` tag.

lib/Acme/Free/Advice.pm  view on Meta::CPAN


=encoding utf-8

=head1 NAME

Acme::Free::Advice - Wise words. Dumb code.

=head1 SYNOPSIS

    use Acme::Free::Advice qw[advice];
    say advice;

=head1 DESCRIPTION

Acme::Free::Advice spits out advice. Good advice. Bad advice. Advice. It's a fortune cookie.

=head1 METHODS

These functions may be imported by name or with the C<:all> tag.

=head2 C<advice( [...] )>

script/advice.pl  view on Meta::CPAN

#
my $raw = 0;
my $flavor;

sub _echo ($advice) {
    $raw && eval 'require JSON::Tiny' ? JSON::Tiny::encode_json( {%$advice} ) : $advice;
}
GetOptions(
    \my %h, 'language=s',
    'help'         => sub { pod2usage( -exitval => 1 ) },
    'flavors!'     => sub { exit !say 'Supported advice flavors: ' . join ', ', Acme::Free::Advice::flavors() },
    'json!'        => \$raw,
    'slip!'        => sub { $flavor = 'slip' },
    'unsolicited!' => sub { $flavor = 'unsolicited' }
);
my $advice = Acme::Free::Advice::advice($flavor);
exit !( $advice ? say _echo($advice) : !say( $raw ? 'null' : '' ) );
__END__

=head1 NAME

advice - Generate advice on the terminal

=head1 SYNOPSIS

    advice                               # generate a random advice
    advice -json                         # grab advice if you're a robot



( run in 1.424 second using v1.01-cache-2.11-cpan-d7f47b0818f )