Venus::Opts
Opts Class
Opts Class for Perl 5
method: default method: exists method: get method: name method: parse method: reparse 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(string $key) (boolean)
{ 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(string $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) (Venus::Opts)
{ since => '0.01', }
=example-1 parse
# given: synopsis;
my $parse = $opts->parse;
# bless({...}, 'Venus::Opts')
The reparse method resets the parser, calls the "parse" method and returns the result.
reparse(arrayref $specs, arrayref $args) (Venus::Opts)
{ since => '2.55', }
The name method takes a name or index and returns index if the the associated value exists.
name(string $key) (string | 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(string $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: present: authors t/Venus.t: present: license
45 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 52:
Unknown directive: =synopsis
- Around line 83:
Unknown directive: =description
- Around line 91:
Unknown directive: =inherits
- Around line 99:
Unknown directive: =integrates
- Around line 110:
Unknown directive: =attributes
- Around line 122:
Unknown directive: =method
- Around line 126:
Unknown directive: =signature
- Around line 130:
Unknown directive: =metadata
- Around line 154:
Unknown directive: =method
- Around line 159:
Unknown directive: =signature
- Around line 163:
Unknown directive: =metadata
- Around line 195:
=cut found outside a pod block. Skipping to next block.
- Around line 213:
=cut found outside a pod block. Skipping to next block.
- Around line 223:
Unknown directive: =method
- Around line 227:
Unknown directive: =signature
- Around line 231:
Unknown directive: =metadata
- Around line 263:
=cut found outside a pod block. Skipping to next block.
- Around line 281:
=cut found outside a pod block. Skipping to next block.
- Around line 291:
Unknown directive: =method
- Around line 297:
Unknown directive: =signature
- Around line 301:
Unknown directive: =metadata
- Around line 334:
=cut found outside a pod block. Skipping to next block.
- Around line 345:
Unknown directive: =method
- Around line 350:
Unknown directive: =signature
- Around line 354:
Unknown directive: =metadata
- Around line 370:
=cut found outside a pod block. Skipping to next block.
- Around line 389:
=cut found outside a pod block. Skipping to next block.
- Around line 400:
Unknown directive: =method
- Around line 405:
Unknown directive: =signature
- Around line 409:
Unknown directive: =metadata
- Around line 441:
=cut found outside a pod block. Skipping to next block.
- Around line 459:
=cut found outside a pod block. Skipping to next block.
- Around line 469:
Unknown directive: =method
- Around line 474:
Unknown directive: =signature
- Around line 478:
Unknown directive: =metadata
- Around line 510:
=cut found outside a pod block. Skipping to next block.
- Around line 528:
=cut found outside a pod block. Skipping to next block.
- Around line 538:
Unknown directive: =method
- Around line 543:
Unknown directive: =signature
- Around line 547:
Unknown directive: =metadata
- Around line 571:
Unknown directive: =partials