#!perl

# Note: This script is a CLI interface to Riap function /Perinci/Examples/test_binary
# and generated automatically using Dist::Zilla::Plugin::Rinci::ScriptFromFunc version 0.08

our $DATE = '2015-02-06'; # DATE
our $VERSION = '0.06'; # VERSION

use 5.010001;
use strict;
use warnings;

use Perinci::Examples;

use Perinci::CmdLine::Classic;

Perinci::CmdLine::Classic->new(
    url => "/Perinci/Examples/test_binary",
)->run;

# ABSTRACT: Accept and send binary data
# PODNAME: peri-eg-test-binary-files

__END__

=pod

=encoding UTF-8

=head1 NAME

peri-eg-test-binary-files - Accept and send binary data

=head1 VERSION

This document describes version 0.06 of peri-eg-test-binary-files (from Perl distribution Perinci-Examples-Bin-Classic), released on 2015-02-06.

=head1 SYNOPSIS

Usage:

 % peri-eg-test-binary-files [options]

=head1 DESCRIPTION

This function sets its argument's schema type as C<buf> which indicates the
argument accepts binary data. Likewise it also sets its result's schema type as
C<buf> which says that function will return binary data.

The function just returns its argument.

Note that since the metadata also contains null ("\0") in the C<default> property
of the argument specification, the metadata is also not JSON-safe.

To pass binary data over JSON/Riap, you can use Riap version 1.2 and encode the
argument with ":base64" suffix, e.g.:

 $res = Perinci::Access->new->request(
     call => "http://example.com/api/Perinci/Examples/test_binary",
     {v=>1.2, args=>{"data:base64"=>"/wA="}}); # send "\xff\0"

Without C<< v=E<gt>1.2 >>, encoded argument won't be decoded by the server.

To pass binary data on the command-line, you can use C<--ARG-base64> if the
command-line library provides it.

To receive binary result over JSON/Riap, you can use Riap version 1.2 which will
automatically encode binary data with base64 so it is safe when transformed as
JSON. The client library will also decode the encoded result back to the
original, so the whole process is transparent to you:

 $res = Perinci::Access->new->request(
     call => "http://example.com/api/Perinci/Examples/test_binary",
     {v=>1.2}); # => [200,"OK","\0\0\0",{}]

=head1 OPTIONS

C<*> marks required options.

=over

=item B<--config-path>=I<s>

{en_US Set path to configuration file}.

Can be specified multiple times.

=item B<--config-profile>=I<s>

{en_US Set configuration profile to use}.

=item B<--data-base64>=I<s>

See C<--data>.

=item B<--data>=I<s>

Default value:

 "\0\0\0"

=item B<--format-options>=I<s>

{en_US Pass options to formatter}.

=item B<--format>=I<s>

{en_US Choose output format, e.g. json, text}.

=item B<--help>, B<-h>, B<-?>

{en_US Display this help message}.

=item B<--json>

{en_US Equivalent to --format=json-pretty}.

=item B<--no-config>

{en_US Do not use any configuration file}.

=item B<--version>, B<-v>

=back

=head1 FILES

~/.conf

/etc/.conf

=head1 COMPLETION

This script has shell tab completion capability with support for several shells.

=head2 bash

To activate bash completion for this script, put:

 complete -C peri-eg-test-binary-files peri-eg-test-binary-files

in your bash startup (e.g. C<~/.bashrc>). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.

It is recommended, however, that you install L<shcompgen> which allows you to activate completion scripts for several kinds of scripts on multiple shells. Some CPAN distributions (those that are built with L<Dist::Zilla::Plugin::GenShellCompletion>) will even automatically enable shell completion for their included scripts (using C<shcompgen>) at installation time, so you can immadiately have tab completion.

=head2 tcsh

To activate tcsh completion for this script, put:

 complete peri-eg-test-binary-files 'p/*/`peri-eg-test-binary-files`/'

in your tcsh startup (e.g. C<~/.tcshrc>). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.

It is also recommended to install C<shcompgen> (see above).

=head2 other shells

For fish and zsh, install C<shcompgen> as described above.

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/Perinci-Examples-Bin-Classic>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-Perinci-Examples-Bin>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Examples-Bin-Classic>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
