Venus::Opts
Opts Class
Opts Class for Perl 5
method: default method: exists method: get method: parse method: name method: set method: unnamed
package main;
use Venus::Opts;
my $opts = Venus::Opts->new(
value => ['--resource', 'users', '--help'],
specs => ['resource|r=s', 'help|h'],
named => { method => 'resource' } # optional
);
# $opts->method; # $resource
# $opts->get('resource'); # $resource
# $opts->help; # $help
# $opts->get('help'); # $help
This package provides methods for handling command-line arguments.
Venus::Kind::Utility
Venus::Role::Accessible Venus::Role::Buildable Venus::Role::Proxyable Venus::Role::Valuable
named: rw, opt, HashRef, {} parsed: rw, opt, HashRef, {} specs: rw, opt, ArrayRef, [] warns: rw, opt, ArrayRef, [] unused: rw, opt, ArrayRef, []
The default method returns the default value, i.e. [@ARGV].
default() (ArrayRef)
{ since => '0.01', }
=example-1 default
# given: synopsis;
my $default = $opts->default;
# []
The exists method takes a name or index and returns truthy if an associated value exists.
exists(Str $key) (Bool)
{ since => '0.01', }
=example-1 exists
# given: synopsis;
my $exists = $opts->exists('resource');
# 1
The get method takes a name or index and returns the associated value.
get(Str $key) (Any)
{ since => '0.01', }
=example-1 get
# given: synopsis;
my $get = $opts->get('resource');
# "users"
The parse method optionally takes additional Getopt::Long parser configuration options and retuns the options found based on the object args and spec values.
parse(ArrayRef $args) (Opts)
{ since => '0.01', }
=example-1 parse
# given: synopsis;
my $parse = $opts->parse;
# { help => 1, resource => "users" }
The name method takes a name or index and returns index if the the associated value exists.
name(Str $key) (Str | Undef)
{ since => '0.01', }
=example-1 name
# given: synopsis;
my $name = $opts->name('resource');
# "resource"
The set method takes a name or index and sets the value provided if the associated argument exists.
set(Str $key, Any $data) (Any)
{ since => '0.01', }
=example-1 set
# given: synopsis;
my $set = $opts->set('method', 'people');
# "people"
The unnamed method returns an arrayref of values which have not been named using the named attribute.
unnamed() (ArrayRef)
{ since => '0.01', }
=example-1 unnamed
# given: synopsis;
my $unnamed = $opts->unnamed;
# [1]
t/Venus.t: pdml: authors t/Venus.t: pdml: license
40 POD Errors
The following errors were encountered while parsing the POD:
- Around line 13:
Unknown directive: =name
- Around line 21:
Unknown directive: =tagline
- Around line 29:
Unknown directive: =abstract
- Around line 37:
Unknown directive: =includes
- Around line 51:
Unknown directive: =synopsis
- Around line 82:
Unknown directive: =description
- Around line 90:
Unknown directive: =inherits
- Around line 98:
Unknown directive: =integrates
- Around line 109:
Unknown directive: =attributes
- Around line 121:
Unknown directive: =method
- Around line 125:
Unknown directive: =signature
- Around line 129:
Unknown directive: =metadata
- Around line 153:
Unknown directive: =method
- Around line 158:
Unknown directive: =signature
- Around line 162:
Unknown directive: =metadata
- Around line 194:
=cut found outside a pod block. Skipping to next block.
- Around line 212:
=cut found outside a pod block. Skipping to next block.
- Around line 222:
Unknown directive: =method
- Around line 226:
Unknown directive: =signature
- Around line 230:
Unknown directive: =metadata
- Around line 262:
=cut found outside a pod block. Skipping to next block.
- Around line 280:
=cut found outside a pod block. Skipping to next block.
- Around line 290:
Unknown directive: =method
- Around line 296:
Unknown directive: =signature
- Around line 300:
Unknown directive: =metadata
- Around line 332:
=cut found outside a pod block. Skipping to next block.
- Around line 342:
Unknown directive: =method
- Around line 347:
Unknown directive: =signature
- Around line 351:
Unknown directive: =metadata
- Around line 383:
=cut found outside a pod block. Skipping to next block.
- Around line 401:
=cut found outside a pod block. Skipping to next block.
- Around line 411:
Unknown directive: =method
- Around line 416:
Unknown directive: =signature
- Around line 420:
Unknown directive: =metadata
- Around line 452:
=cut found outside a pod block. Skipping to next block.
- Around line 470:
=cut found outside a pod block. Skipping to next block.
- Around line 480:
Unknown directive: =method
- Around line 485:
Unknown directive: =signature
- Around line 489:
Unknown directive: =metadata
- Around line 513:
Unknown directive: =partials