Perinci-Examples-Bin-Classic
view release on metacpan or search on metacpan
script/peri-eg-read-file view on Meta::CPAN
=head1 SYNOPSIS
Usage:
% peri-eg-read-file [--config-path=path+] [--config-profile=profile]
[--format-options=s] [--format=name] [--json] [--(no)naked-res]
[--no-config] [--no-env] <path>
=head1 DESCRIPTION
This function demonstrate output streaming of bytes.
To do output streaming, on the function side, you just return a coderef which
can be called by caller (e.g. CLI framework L<Perinci::CmdLine>) to read data
from. Code must return data or undef to signify exhaustion.
This works over remote (HTTP) too, because output streaming is supported by
L<Riap::HTTP> (version 1.2) and L<Perinci::Access::HTTP::Client>. Streams
are translated into HTTP chunks.
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
script/peri-eg-write-file view on Meta::CPAN
=head1 SYNOPSIS
Usage:
% peri-eg-write-file [--config-path=path+] [--config-profile=profile]
[--format-options=s] [--format=name] [--json] [--(no)naked-res]
[--no-config] [--no-env] <path> <content>
=head1 DESCRIPTION
This function demonstrates input streaming of bytes.
To do input streaming, on the function side, you just specify one your args with
the C<stream> property set to true (C<< stream =E<gt> 1 >>). In this example, the
C<content> argument is set to streaming.
If you run the function through L<Perinci::CmdLine>, you'll get a coderef
instead of the actual value. You can then repeatedly call the code to read data.
This currently works for local functions only. As of this writing,
L<Riap::HTTP> protocol does not support input streaming. It supports partial
input though (see the documentation on how this works) and theoretically
streaming can be emulated by client library using partial input. However, client
like L<Perinci::Access::HTTP::Client> does not yet support this.
Note that the argument's schema is still C<buf*>, not C<code*>.
Note: This function overwrites existing file.
=head1 OPTIONS
C<*> marks required options.
( run in 0.353 second using v1.01-cache-2.11-cpan-4d50c553e7e )