Agent-TCLI
view release on metacpan or search on metacpan
lib/Agent/TCLI/Control.pm view on Meta::CPAN
package Agent::TCLI::Control;
# $Id: Control.pm 62 2007-05-03 15:55:17Z hacker $
=pod
=head1 NAME
Agent::TCLI::Control - Manage TCLI commands
=head1 SYNOPSIS
Controls are spawned from within Transports. One does not need to
manipulate to create typical Agents.
Control is very poorly documented at this point.
I apologize for the inconvenience.
=head1 DESCRIPTION
Why is it that people like GUIs so much? One of the reasons is because a
good GUI allows people to spend less time memorizing the syntax and
language specifics within a program. If one has no clue what a particular
command is, one can still check out all the menus until something is found.
With a command line, this type of hunt and peck is more difficult, but not
impossible. The command line must be command contextual to do this. A typical
operating system interface maintains a file system context and not a
command context. Cisco IOS and other network equipment often use a command
contextual interface, and this is sometimes called Cisco-like.
Network equipment usually has a much simpler file system
and Network Administrators are usually forced to manage many more types of
devices than System Administrators. Network Systems also generally require much less
daily contact, so it is important for the user interface to be as helpful
as possible, because the operator has likely forgotten half of the command
syntax.
For functional quality assurance testing, the demands are much more in line with Network
Administration. One will need to plug in a module that tests some sort
of capability, write and run some tests, and then do something else for
a bit while the developers/integrators fix the problems. Thus TCLI attempts
to use the Cisco-like contextual paradigm to provide a user interface to
support testers.
=cut
use warnings;
use strict;
use POE;
use Carp;
use Object::InsideOut qw(Agent::TCLI::Package::Base);
use Agent::TCLI::Request;
use Agent::TCLI::Response;
use Agent::TCLI::Command;
use Agent::TCLI::Parameter;
use Params::Validate;
#use Data::Dump qw(pp);
use Text::ParseWords;
#sub VERBOSE () { 0 }
our $VERSION = '0.030.'.sprintf "%04d", (qw($Id: Control.pm 62 2007-05-03 15:55:17Z 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 id
ID of control. MUST be unique to all other controls and is the POE kernel alias.
lib/Agent/TCLI/Control.pm view on Meta::CPAN
$self->Verbose("ARG1 dumped",1,$_[ARG1]) if defined($_[ARG1]);
$self->Verbose("ARG2 dumped",1,$_[ARG2]) if defined($_[ARG2]);
return(0);
}
=item _default_commands
A private object method that has all the default commands.
The ones we just can't live without. Well, maybe not all the ones we can't
live without, but all the ones that have actually be written so far.
=cut
sub _default_commands :Private {
my $self = shift;
my $dc = {
'echo' => Agent::TCLI::Command->new(
'name' => 'echo',
'help' => 'Return what was said.',
'usage' => 'echo <something> or /echo ...',
'topic' => 'general',
'command' => 'pre-loaded',
'contexts' => {'UNIVERSAL' => 'echo'},
'call_style'=> 'state',
'handler' => 'general'
),
'Hi' => Agent::TCLI::Command->new(
'name' => 'Hi',
'help' => 'Greetings',
'usage' => 'Hi/Hello',
'topic' => 'general',
'command' => 'pre-loaded',
'contexts' => {'ROOT' => [ qw(Hi hi Hello hello)]},
'call_style'=> 'state',
'handler' => 'general'
),
'context' => Agent::TCLI::Command->new(
'name' => 'context',
'help' => "displays the current context",
'usage' => 'context or /context',
'manual' => "Context can be somewhat difficult to understand when one thinks of normal command line interfaces that often retain context differently. ".
"Context is a way of nesting commands, much like a file directory, to make it easier to navigate. There are a few commands, such as 'help' or 'exit' that are global, ".
"but most commands are available only within specific contexts. Well written packages will collect groups of similar commands within a context. ".
"For instance, if one had package of attack commands, one would put them all in an 'attack' context. Instead of typing 'attack one target=example.com', ".
"one could type 'attack' to change to the attack context then type 'one target=example.com' followed by 'two target=example.com' etc. \n\n".
"Furthermore, a well written package will support the setting of default parameters for use within a context. One can then say: \n ".
"\tattack \n\tset target=example.com \n\tone \n\ttwo \n\t...\n\n".
"The full command 'attack one target=example.com' must always be supported, but using context makes it easier to do repetitive tasks manually as well as ".
"allow one to navigate through a command syntax that one's forgotten the details of without too much trouble. \n\n".
"Context has a sense of depth, as in how many commands one has in front of whatever one is currently typing. ".
"An alias to the context command is 'pwd' which stands for Present Working Depth. ".
"Though it may make the Unix geeks happy, they should remember that this is not a file directory structure that one is navigating within.",
'topic' => 'general',
'command' => 'pre-loaded',
'contexts' => {'UNIVERSAL' => [ qw( context pwd ) ]},
'call_style'=> 'state',
'handler' => 'general'
),
'Verbose' => Agent::TCLI::Command->new(
'name' => 'Verbose',
'help' => "changes the verbosity of output to logs",
'usage' => 'Verbose',
'topic' => 'admin',
'command' => 'pre-loaded',
'contexts' => {'UNIVERSAL' => 'Verbose'},
'call_style'=> 'state',
'handler' => 'general'
),
'debug_request' => Agent::TCLI::Command->new(
'name' => 'debug_request',
'help' => 'show what the request object contains',
'usage' => 'debug_request <some other args>',
'topic' => 'admin',
'command' => 'pre-loaded',
'contexts' => {'UNIVERSAL' => 'debug_request'},
'call_style'=> 'state',
'handler' => 'general'
),
'help' => Agent::TCLI::Command->new(
'name' => 'help',
'help' => 'Display help about available commands',
'usage' => 'help [ command ] or /help',
'manual' => 'The help command provides summary information about running a command and the parameters the command accepts. Help with no arguments will list the currently available commands. Help is currently broken in that it only operates wi...
'topic' => 'general',
'command' => 'pre-loaded',
'contexts' => {'UNIVERSAL' => 'help'},
'call_style'=> 'state',
'handler' => 'help'
),
'manual' => Agent::TCLI::Command->new(
'name' => 'manual',
'help' => 'Display detailed help about a command',
'usage' => 'manual [ command ]',
'manual' => 'The manual command provides detailed information about running a command and the parameters the command accepts. Manual is currently broken in that it only operates within the existing context and cannot be called with a full con...
'topic' => 'general',
'command' => 'pre-loaded',
'contexts' => {'UNIVERSAL' => ['manual', 'man'] },
'call_style'=> 'state',
'handler' => 'manual'
),
'status' => Agent::TCLI::Command->new(
'name' => 'status',
'help' => 'Display general TCLI control status',
'usage' => 'status or /status',
'topic' => 'general',
'command' => 'pre-loaded',
'contexts' => {'UNIVERSAL' => 'status'},
'call_style'=> 'state',
'handler' => 'general'
),
'/' => Agent::TCLI::Command->new(
'name' => 'root',
'help' => "exit to root context, use '/command' for a one time switch",
'usage' => 'root or / ',
'manual' => "root, or '/' for the Unix geeks, will change the context back to root. See 'manual context' for more information on context. ".
"Unless otherwise noted, changing to root context does not normally clear out any default settings that were established in that context. \n\n".
"One can preceed a command directly with a '/' such as '/exit' to force the root context. ".
"Sometimes a context may independently process everything said within the context and, if misbehaving, doesn't provide a way to leave the context. ".
"Using '/exit' or '/help' should always work. The example package Eliza is known to have trouble saying Goodbye and exiting properly.",
'topic' => 'general',
'command' => 'pre-loaded',
( run in 0.871 second using v1.01-cache-2.11-cpan-39bf76dae61 )