Venus::Opts
Opts Class
Opts Class for Perl 5
method: default method: exists method: get method: name method: new 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 new method constructs an instance of the package.
new(any @args) (Venus::Opts)
{ since => '4.15', }
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
51 POD Errors
The following errors were encountered while parsing the POD:
- Around line 14:
Unknown directive: =name
- Around line 22:
Unknown directive: =tagline
- Around line 30:
Unknown directive: =abstract
- Around line 38:
Unknown directive: =includes
- Around line 54:
Unknown directive: =synopsis
- Around line 85:
Unknown directive: =description
- Around line 93:
Unknown directive: =inherits
- Around line 101:
Unknown directive: =integrates
- Around line 112:
Unknown directive: =attributes
- Around line 124:
Unknown directive: =method
- Around line 128:
Unknown directive: =signature
- Around line 132:
Unknown directive: =metadata
- Around line 156:
Unknown directive: =method
- Around line 161:
Unknown directive: =signature
- Around line 165:
Unknown directive: =metadata
- Around line 197:
=cut found outside a pod block. Skipping to next block.
- Around line 215:
=cut found outside a pod block. Skipping to next block.
- Around line 225:
Unknown directive: =method
- Around line 229:
Unknown directive: =signature
- Around line 233:
Unknown directive: =metadata
- Around line 265:
=cut found outside a pod block. Skipping to next block.
- Around line 283:
=cut found outside a pod block. Skipping to next block.
- Around line 293:
Unknown directive: =method
- Around line 297:
Unknown directive: =signature
- Around line 301:
Unknown directive: =metadata
- Around line 319:
=cut found outside a pod block. Skipping to next block.
- Around line 342:
=cut found outside a pod block. Skipping to next block.
- Around line 365:
=cut found outside a pod block. Skipping to next block.
- Around line 376:
Unknown directive: =method
- Around line 382:
Unknown directive: =signature
- Around line 386:
Unknown directive: =metadata
- Around line 419:
=cut found outside a pod block. Skipping to next block.
- Around line 430:
Unknown directive: =method
- Around line 435:
Unknown directive: =signature
- Around line 439:
Unknown directive: =metadata
- Around line 455:
=cut found outside a pod block. Skipping to next block.
- Around line 474:
=cut found outside a pod block. Skipping to next block.
- Around line 485:
Unknown directive: =method
- Around line 490:
Unknown directive: =signature
- Around line 494:
Unknown directive: =metadata
- Around line 526:
=cut found outside a pod block. Skipping to next block.
- Around line 544:
=cut found outside a pod block. Skipping to next block.
- Around line 554:
Unknown directive: =method
- Around line 559:
Unknown directive: =signature
- Around line 563:
Unknown directive: =metadata
- Around line 595:
=cut found outside a pod block. Skipping to next block.
- Around line 613:
=cut found outside a pod block. Skipping to next block.
- Around line 623:
Unknown directive: =method
- Around line 628:
Unknown directive: =signature
- Around line 632:
Unknown directive: =metadata
- Around line 656:
Unknown directive: =partials