NAME

Net::CLI::Interact::Role::Engine - Statement execution engine

DESCRIPTION

This module is the core of Net::CLI::Interact, and serves to take entries from your loaded Phrasebooks, issue them to connected devices, and gather the returned output.

INTERFACE

cmd( $command_statement, \%options? )

Execute a single command statement on the connected device, and consume output until there is a match with the current prompt. The statement is executed verbatim on the device, with a newline appended.

The following options are supported:

timeout => $seconds (optional)

Sets a value of timeout for the Transport local to this call of cmd, that overrides whatever is set in the Transport, or the default of 10 seconds.

no_ors => 1 (optional)

When passed a true value, a newline character (in fact the value of ors) will not be appended to the statement sent to the device.

match => $name | $regexpref | \@names_and_regexprefs (optional)

Allows this command (only) to complete with a custom match, which must be one or more of either the name of a loaded phrasebook Prompt or your own regular expression reference (qr//). The module updates the current prompt to be the same value on a successful match.

In scalar context the last_response is returned (see below). In list context the gathered response is returned as a list of lines. In both cases your local platform's newline character will end all lines.

macro( $macro_name, \%options? )

Execute the commands contained within the named Macro, which must be loaded from a Phrasebook. Options to control the output, including variables for substitution into the Macro, are passed in the %options hash reference.

The following options are supported:

params => \@values (optional)

If the Macro contains commands using sprintf Format variables then the corresponding parameters must be passed in this value as an array reference.

Values are consumed from the provided array reference and passed to the send commands in the Macro in order, as needed. An exception will be thrown if there are insufficient parameters.

timeout => $seconds (optional)

Sets a value of timeout for the Transport local to this call of macro, that overrides whatever is set in the Transport, or the default of 10 seconds.

An exception will be thrown if the Match statements in the Macro are not successful against the output returned from the device. This is based on the value of timeout, which controls how long the module waits for matching output.

In scalar context the last_response is returned (see below). In list context the gathered response is returned as a list of lines. In both cases your local platform's newline character will end all lines.

last_response

Returns the gathered output after issuing the last recent send command within the most recent cmd or prompt. That is, you get the output from the last command sent to the connected device.

In scalar context all data is returned. In list context the gathered response is returned as a list of lines. In both cases your local platform's newline character will end all lines.

last_actionset

Returns the complete ActionSet that was constructed from the most recent macro or cmd execution. This will be a sequence of Actions that correspond to send and match statements.

In the case of a Macro these directly relate to the contents of your Phrasebook, with the possible addition of match statements added automatically. In the case of a cmd execution, an "anonymous" Macro is constructed which consists of a single send and a single match.

COMPOSITION

See the following for further interface details: