Agent-TCLI
view release on metacpan or search on metacpan
lib/Agent/TCLI/Control.pm view on Meta::CPAN
# # we don't know how deep we're in already. So we'll force a full context shift.
# # by sending the entire command array back, which is revesred.
# my @context = reverse (@{$request->command});
#
# # We don't actualy set the controls context, but let change context do that.
# # It will also inform the user of change.
#
# # Post context back to sender (Control)
# $kernel->call( $sender => 'ChangeContext' => $request, \@context );
# $self->Verbose("establish_context: setting context to "
# .join(' ',@context)." ",2);
#
#}
#
#=item show
#
#This POE event handler i will accept an argument for the setting to show.
#It will also take an argument of all or * and show all settings.
#
#The parameter must be defined in the command entry's parameters or it will
#not be shown. There must also be a OIO Field defined with the same name.
#One may write their own show method if this is not sufficient.
#
#=cut
#
#sub show {
# my ($kernel, $self, $sender, $request, ) =
# @_[KERNEL, OBJECT, SENDER, ARG0, ];
# $self->Verbose("show: request(".$request->id.") ",2);
#
# my ($txt, $code, $what, $var);
# # calling with show as a command, that is the handler for show is show.
# if ( $request->command->[0] eq 'show' ) # cmd1 show arg
# # cmd1 attacks show <arg>
# {
# $what = $request->args->[0];
# }
#
# $self->Verbose("show: what(".$what.") request->args",1,$request->args);
#
# ATTR: foreach my $attr ( keys %{ $self->commands->{'show'}->parameters } )
# {
# if ( $what eq $attr || $what =~ qr(^(\*|all)$))
# {
# if ( $self->can( $attr ) && defined( $self->$attr) )
# {
# my $ref = ref($self->$attr);
# my $show = ( defined($self->parameters ) &&
# defined($self->parameters->{ $attr } ) &&
# defined($self->parameters->{ $attr }->show_method ) )
# ? $self->parameters->{ $attr }->show_method
# : '';
# $self->Verbose("show attr($attr) ref($ref) show($show)",1);
# # simple scalar
# if ( not $ref)
# {
# $txt .= "$attr: ".$self->$attr." \n";
# $code = 200;
# }
# # is it an object and show_method is defined?.
# elsif ( $ref =~ qr(::) && blessed( $self->$attr )
# && $show )
# {
# $txt .= "$attr: ".$self->$attr->$show."\n";
# $code = 200;
# }
# # is it an object with dump? Probably OIO.
# elsif ( $ref =~ qr(::) && blessed($self->$attr)
# && $self->$attr->can( 'dump') )
# {
# $var = $self->$attr->dump(0);
# $txt .= Dump($var)."\n";
# $code = 200;
# }
# elsif ( $ref =~ qr(HASH) )
# {
# foreach my $key ( sort keys %{$self->$attr} )
# {
# my $subref = ref($self->$attr->{ $key } );
# $self->Verbose("show key($key) subref($subref)",0);
# # simple scalar
# if ( not $subref )
# {
# $txt .= "$attr ->{ $key }: ".$self->$attr->{$key}." \n";
# $code = 200;
# }
# # is it an object and show_method is defined?.
# elsif ( $subref =~ qr(::) &&
# blessed($self->$attr->{ $key }) &&
# defined($show) )
# {
# $txt .= "$attr: ".$self->$attr->{$key}->$show."\n";
# $code = 200;
# }
# # is it an object with dump? Probably OIO.
# elsif ( $subref =~ qr(::) &&
# blessed($self->$attr->{ $key }) &&
# $self->$attr->{ $key }->can( 'dump') )
# {
# $var = $self->$attr->{$key}->dump(0);
# $txt .= Dump($var)."\n";
# $code = 200;
# }
# # some other object, array or hash
# else
# {
# $var = $self->$attr->{$key};
# $txt .= Dump($var)."\n";
# $code = 200;
# }
# }
# }
# elsif ( $ref =~ qr(ARRAY) )
# {
# my $i = 0;
# foreach my $val ( @{$self->$attr} )
# {
# my $subref = ref( $val );
# # simple scalar
# if ( not $subref )
# {
# $txt .= "$attr ->[ $i ]: ".$val." \n";
# $code = 200;
# }
# # is it an object and show_method is defined?.
# elsif ( $subref =~ qr(::) &&
# blessed($val) &&
# defined($show) )
# {
# $txt .= "$attr: ".$val->$show."\n";
# $code = 200;
# }
# # is it an object with dump? Probably OIO.
# elsif ( $subref =~ qr(::) &&
# blessed($val) &&
# $val->can( 'dump') )
# {
# $var = $val->dump(0);
# $txt .= Dump($var)."\n";
# $code = 200;
# }
# # some other object, array or hash
# else
# {
# $txt .= Dump($val)."\n";
# $code = 200;
# }
# }
# }
# # some other object
# else
# {
# $var = $self->$attr;
# $txt .= Dump($var)."\n";
# $code = 200;
# }
# }
# elsif ( $self->can( $attr ) )
# {
# $txt = $what.": #!undefined";
# $code = 200;
# }
# else # should get here, but might if parameter error.
# {
# $txt = $what.": #!ERROR does not exist";
# $code = 404;
# }
# }
# }
#
# # if we didn't find anything at all, then a 404 is returned
# if (!defined($txt) || $txt eq '' )
# {
# $txt = $what.": #!ERROR not found";
# $code = 404;
# }
#
# $request->Respond($kernel, $txt, $code);
#}
#
#=item settings
#
#This POE event handler executes the set commands.
#
#=cut
#
#sub settings { # Can't call it set
# my ($kernel, $self, $sender, $request, ) =
# @_[KERNEL, OBJECT, SENDER, ARG0, ];
#
# my $txt = '';
# my ($param, $code);
# my $command = $request->command->[0];
# # called directly because $command may be an alias and not the real name
# my $cmd = $self->commands->{'set'};
( run in 1.964 second using v1.01-cache-2.11-cpan-39bf76dae61 )