Agent-TCLI
view release on metacpan or search on metacpan
lib/Agent/TCLI/Parameter.pm view on Meta::CPAN
package Agent::TCLI::Parameter;
#
# $Id: Parameter.pm 59 2007-04-30 11:24:24Z hacker $
#
=head1 NAME
Agent::TCLI::Parameter - A Parameter class for TCLI.
=head1 SYNOPSIS
#within a Agent::TCLI::Package module that
#inherits from Agent::TCLI::Package::Base
use Agent::TCLI::Parameter
sub _init :Init{
$self->LoadYaml(<<'...');
---
Agent::TCLI::Parameter:
name: test_verbose
constraints:
- UINT
help: an integer for verbosity
manual: >
This debugging parameter can be used to adjust the verbose setting
for the test transport.
type: counter
...
}
=head1 DESCRIPTION
Parameters are the arguements supplied with a command. TCLI defines them as
objects to make it easier to provide several necessary interface features
in a consistent manner. One can use the new function to create Parameters
to load into a package, but the author prefers the YAML syntax as it is
easier to work with.
Arguement parsing may be done with Getopt::Lucid. One should define the type
if using the provided parsing.
Arguement validation may be performed using FormValidator::Simple constraints
as defined in the parameter. Otherwise it should be performed within the
Package subroutine handling the command.
Typically each Package will have a field defined with a standard
accessor/mutator that represents the default value to be used for the
parameter when the command the command is called. This field can be
manually defined in the Package, or it can be autocreated upon parameter
loading within the Package. If necessary, the class filed may be used to
set the Object::InsideOut type to be used for the field.
The reason for the use of Parameter and Command objects is to push a Package
to be as data driven as possible, with only the only code being the actual
command logic. It was decided that it would be best to evolve towards that
goal, rather than try to get it right from the outset. So what you see what
you get.
=cut
use warnings;
use strict;
use Object::InsideOut qw(Agent::TCLI::Base);
our $VERSION = '0.030.'.sprintf "%04d", (qw($Id: Parameter.pm 59 2007-04-30 11:24:24Z hacker $))[2];
=head1 INTERFACE
=head2 ATTRIBUTES
The following attributes are accessible through standard accessor/mutator
methods and may be set as a parameter to new unless otherwise noted.
=over
=item name
The name of the parameter. The name is what the user supplies as an argument
to the Command. The name will also be used as the hash key when loaded
into the Package, so it must be unique within the set of all other Parameter
names in a package.
The parameter name is also specified in the Command definition within a module,
so the Parameter must be defined and loaded first.
( run in 0.555 second using v1.01-cache-2.11-cpan-39bf76dae61 )