NAME
Venus::Args - Args Class
ABSTRACT
Args Class for Perl 5
SYNOPSIS
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]
DESCRIPTION
This package provides methods for accessing @ARGS
items.
ATTRIBUTES
This package has the following attributes:
named
named(HashRef)
This attribute is read-write, accepts (HashRef)
values, is optional, and defaults to {}
.
INHERITS
This package inherits behaviors from:
INTEGRATES
This package integrates behaviors from:
METHODS
This package provides the following methods:
default
default() (ArrayRef)
The default method returns the default value, i.e. @ARGV
.
Since 0.01
- default example 1
-
# given: synopsis; my $default = $args->default; # [@ARGV] # ["--help", "execute"]
exists
exists(Str $key) (Bool)
The exists method returns truthy or falsy if an index or alias value exists.
Since 0.01
get
get(Str $key) (Any)
The get method returns the value of the index or alias.
Since 0.01
indexed
indexed() (HashRef)
The indexed method returns a set of indices and values.
Since 0.01
- indexed example 1
-
# given: synopsis; my $indexed = $args->indexed; # { "0" => "--help", "1" => "execute" }
name
name(Str $key) (Str | Undef)
The name method resolves and returns the index for an index or alias, and returns undefined if not found.
Since 0.01
set
set(Str $key, Any $data) (Any)
The set method sets and returns the value of an index or alias.
Since 0.01
unnamed
unnamed() (ArrayRef)
The unnamed method returns a list of unaliases indices.
Since 0.01