Venus::Args
Args Class
Args Class for Perl 5
method: default method: exists method: get method: indexed method: name method: new method: set method: unnamed
package main;
use Venus::Args;
my $args = Venus::Args->new(
named => { flag => 0, command => 1 }, # optional
value => ['--help', 'execute'],
);
# $args->flag; # $ARGV[0]
# $args->get(0); # $ARGV[0]
# $args->get(1); # $ARGV[1]
# $args->action; # $ARGV[1]
# $args->exists(0); # exists $ARGV[0]
# $args->exists('flag'); # exists $ARGV[0]
# $args->get('flag'); # $ARGV[0]
This package provides methods for accessing @ARGS items.
Venus::Kind::Utility
Venus::Role::Accessible Venus::Role::Buildable Venus::Role::Proxyable Venus::Role::Valuable
named: rw, opt, HashRef, {}
The default method returns the default value, i.e. @ARGV.
default() (arrayref)
{ since => '0.01', }
=example-1 default
# given: synopsis;
my $default = $args->default;
# [@ARGV]
# ["--help", "execute"]
The exists method returns truthy or falsy if an index or alias value exists.
exists(string $key) (boolean)
{ since => '0.01', }
=example-1 exists
# given: synopsis;
my $exists = $args->exists(0);
# 1
The get method returns the value of the index or alias.
get(string $key) (any)
{ since => '0.01', }
=example-1 get
# given: synopsis;
my $get = $args->get(0);
# "--help"
The indexed method returns a set of indices and values.
indexed() (hashref)
{ since => '0.01', }
=example-1 indexed
# given: synopsis;
my $indexed = $args->indexed;
# { "0" => "--help", "1" => "execute" }
The name method resolves and returns the index for an index or alias, and returns undefined if not found.
name(string $key) (string | undef)
{ since => '0.01', }
=example-1 name
# given: synopsis;
my $name = $args->name('flag');
The new method constructs an instance of the package.
new(any @args) (Venus::Args)
{ since => '4.15', }
The set method sets and returns the value of an index or alias.
set(string $key, any $data) (any)
{ since => '0.01', }
=example-1 set
# given: synopsis;
my $set = $args->set(0, '-?');
# "-?"
The unnamed method returns a list of unaliases indices.
unnamed() (arrayref)
{ since => '0.01', }
=example-1 unnamed
package main;
use Venus::Args;
my $args = Venus::Args->new(
named => { flag => 0, command => 1 },
value => ['--help', 'execute', '--format', 'markdown'],
);
my $unnamed = $args->unnamed;
# ["--format", "markdown"]
t/Venus.t: present: authors t/Venus.t: present: license
43 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 53:
Unknown directive: =synopsis
- Around line 84:
Unknown directive: =description
- Around line 92:
Unknown directive: =inherits
- Around line 100:
Unknown directive: =integrates
- Around line 111:
Unknown directive: =attributes
- Around line 119:
Unknown directive: =method
- Around line 123:
Unknown directive: =signature
- Around line 127:
Unknown directive: =metadata
- Around line 153:
Unknown directive: =method
- Around line 157:
Unknown directive: =signature
- Around line 161:
Unknown directive: =metadata
- Around line 193:
=cut found outside a pod block. Skipping to next block.
- Around line 211:
=cut found outside a pod block. Skipping to next block.
- Around line 221:
Unknown directive: =method
- Around line 225:
Unknown directive: =signature
- Around line 229:
Unknown directive: =metadata
- Around line 261:
=cut found outside a pod block. Skipping to next block.
- Around line 279:
=cut found outside a pod block. Skipping to next block.
- Around line 289:
Unknown directive: =method
- Around line 293:
Unknown directive: =signature
- Around line 297:
Unknown directive: =metadata
- Around line 321:
Unknown directive: =method
- Around line 326:
Unknown directive: =signature
- Around line 330:
Unknown directive: =metadata
- Around line 352:
Unknown directive: =method
- Around line 356:
Unknown directive: =signature
- Around line 360:
Unknown directive: =metadata
- Around line 378:
=cut found outside a pod block. Skipping to next block.
- Around line 400:
=cut found outside a pod block. Skipping to next block.
- Around line 411:
Unknown directive: =method
- Around line 415:
Unknown directive: =signature
- Around line 419:
Unknown directive: =metadata
- Around line 451:
=cut found outside a pod block. Skipping to next block.
- Around line 469:
=cut found outside a pod block. Skipping to next block.
- Around line 479:
Unknown directive: =method
- Around line 483:
Unknown directive: =signature
- Around line 487:
Unknown directive: =metadata
- Around line 533:
=cut found outside a pod block. Skipping to next block.
- Around line 543:
Unknown directive: =partials