CXC-Form-Tiny-Plugin-OptArgs2
view release on metacpan or search on metacpan
t/OptArgs.t view on Meta::CPAN
#! perl
use v5.20;
use Test2::V0;
use Test::Lib;
use My::Test::AutoCleanHash;
use Data::Dumper;
use OptArgs2;
use experimental 'signatures', 'postderef';
package My::Form {
use Form::Tiny plugins => ['+CXC::Form::Tiny::Plugin::OptArgs2'];
use JSON::PP;
use Types::Standard qw( Any ArrayRef Bool Enum HashRef Str );
use Types::TypeTiny qw( BoolLike );
use Types::Path::Tiny qw( Path File Dir);
use Types::Common::String qw( NonEmptyStr );
form_field 'dir' => ( type => Dir, coerce => 1 );
option( comment => 'existing directory', );
form_field 'file' => ( type => File, coerce => 1 );
option(
comment => 'Query in a file',
isa_name => 'ADQL in a file',
);
form_field 'adql' => ( type => NonEmptyStr, );
option(
comment => 'Query on the command line',
isa_name => 'ADQL',
);
form_field 'url' => (
type => Str,
default => sub { 'https://cda.cfa.harvard.edu/csc2tap' },
);
option(
comment => 'CSC TAP endpoint',
isa_name => 'URL',
show_default => 1,
);
form_field 'output.file' => ( type => Path, coerce => 1 );
option(
name => 'output',
comment => 'File to store parsed results',
isa_name => 'filename',
);
form_field 'output.encoding' => ( type => Enum [ 'json', 'yaml' ], );
option(
name => 'encoding',
comment => sprintf( 'encoding format for --output [%s]', join( ' | ', qw( json yaml ) ) ),
);
form_field 'raw.encoding' => ( type => Enum [ 'foo', 'bar' ], );
option(
name => 'raw-format',
comment => sprintf( 'requested VO format [%s]', join( ' | ', qw( foo bar ) ) ),
);
form_field 'raw.file' => ( type => Path, coerce => 1 );
option(
name => 'raw-output',
comment => 'store raw results from CSC server in this file',
isa_name => 'filename',
);
form_field 'upload' => ( type => HashRef [NonEmptyStr], );
option( comment => 'table name/filename pairs to upload', );
form_field 'vars' => (
type => HashRef [Str],
default => sub { { a => 1 } },
);
option(
name => 'var',
comment => 'variables to interpolate into query template',
);
form_field 'use_db' => (
type => Bool,
default => sub { 0 },
);
option(
name => 'db',
comment => 'output to database instead of a file',
);
form_field 'bool_like' => (
type => BoolLike,
default => sub { JSON::PP::true },
);
option( comment => 'Boolean object' );
form_field 'any_thing_goes' => ( type => Any, );
option( comment => 'the world is your oyster', );
( run in 1.848 second using v1.01-cache-2.11-cpan-524268b4103 )