GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Venus::Args(3) User Contributed Perl Documentation Venus::Args(3)

Venus::Args - Args Class

Args Class for Perl 5

  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.

This package has the following attributes:

  named(HashRef)

This attribute is read-write, accepts "(HashRef)" values, is optional, and defaults to "{}".

This package inherits behaviors from:

Venus::Kind::Utility

This package integrates behaviors from:

Venus::Role::Accessible

Venus::Role::Buildable

Venus::Role::Proxyable

Venus::Role::Valuable

This package provides the following methods:

  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(string $key) (boolean)

The exists method returns truthy or falsy if an index or alias value exists.

Since 0.01

exists example 1
  # given: synopsis;
  my $exists = $args->exists(0);
  # 1
    
exists example 2
  # given: synopsis;
  my $exists = $args->exists('flag');
  # 1
    
exists example 3
  # given: synopsis;
  my $exists = $args->exists(2);
  # undef
    

  get(string $key) (any)

The get method returns the value of the index or alias.

Since 0.01

get example 1
  # given: synopsis;
  my $get = $args->get(0);
  # "--help"
    
get example 2
  # given: synopsis;
  my $get = $args->get('flag');
  # "--help"
    
get example 3
  # given: synopsis;
  my $get = $args->get(2);
  # undef
    

  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(string $key) (string | undef)

The name method resolves and returns the index for an index or alias, and returns undefined if not found.

Since 0.01

name example 1
  # given: synopsis;
  my $name = $args->name('flag');
    

  set(string $key, any $data) (any)

The set method sets and returns the value of an index or alias.

Since 0.01

set example 1
  # given: synopsis;
  my $set = $args->set(0, '-?');
  # "-?"
    
set example 2
  # given: synopsis;
  my $set = $args->set('flag', '-?');
  # "-?"
    
set example 3
  # given: synopsis;
  my $set = $args->set('verbose', 1);
  # undef
    

  unnamed() (arrayref)

The unnamed method returns a list of unaliases indices.

Since 0.01

unnamed example 1
  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"]
    
unnamed example 2
  package main;
  use Venus::Args;
  my $args = Venus::Args->new(
    named => { command => 1 },
    value => ['execute', 'phase-1', '--format', 'markdown'],
  );
  my $unnamed = $args->unnamed;
  # ["execute", "--format", "markdown"]
    

Awncorp, "awncorp@cpan.org"

Copyright (C) 2022, Awncorp, "awncorp@cpan.org".

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.

2023-11-27 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.