Venus::Args
Args Class
Args Class for Perl 5
method: default method: exists method: get method: indexed method: name 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(Str $key) (Bool)
{ 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(Str $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(Str $key) (Str | Undef)
{ since => '0.01', }
=example-1 name
# given: synopsis;
my $name = $args->name('flag');
The set method sets and returns the value of an index or alias.
set(Str $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: pdml: authors t/Venus.t: pdml: license
38 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 117:
Unknown directive: =method
- Around line 121:
Unknown directive: =signature
- Around line 125:
Unknown directive: =metadata
- Around line 151:
Unknown directive: =method
- Around line 155:
Unknown directive: =signature
- Around line 159:
Unknown directive: =metadata
- Around line 191:
=cut found outside a pod block. Skipping to next block.
- Around line 209:
=cut found outside a pod block. Skipping to next block.
- Around line 219:
Unknown directive: =method
- Around line 223:
Unknown directive: =signature
- Around line 227:
Unknown directive: =metadata
- Around line 259:
=cut found outside a pod block. Skipping to next block.
- Around line 277:
=cut found outside a pod block. Skipping to next block.
- Around line 287:
Unknown directive: =method
- Around line 291:
Unknown directive: =signature
- Around line 295:
Unknown directive: =metadata
- Around line 319:
Unknown directive: =method
- Around line 324:
Unknown directive: =signature
- Around line 328:
Unknown directive: =metadata
- Around line 350:
Unknown directive: =method
- Around line 354:
Unknown directive: =signature
- Around line 358:
Unknown directive: =metadata
- Around line 390:
=cut found outside a pod block. Skipping to next block.
- Around line 408:
=cut found outside a pod block. Skipping to next block.
- Around line 418:
Unknown directive: =method
- Around line 422:
Unknown directive: =signature
- Around line 426:
Unknown directive: =metadata
- Around line 472:
=cut found outside a pod block. Skipping to next block.
- Around line 482:
Unknown directive: =partials