Net::C...tionSet(3pm)

πŸ“¦
version 2.400002 Β· 6 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Net::CLI::Interact::ActionSet ✨

okay bestie, quick vibe check: this is a page from the User Contributed Perl Documentation collection, and honestly? It's giving internal plumbing πŸ’…

🌸 NAME 🌸

Net::CLI::Interact::ActionSet β€” a whole conversation of Send and Match Actions πŸ—£οΈπŸ’¬


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea, bestie: this class is used internally by Net::CLI::Interact, and it's unlikely that an end-user is ever gonna need to make ActionSet objects directly. The interface is documented here as a matter of record. Like, it's on the record, it's in the group chat, it's immortalized. 🫢

An ActionSet is made up of a sequence β€” usefully, two or more β€” of Actions that describe a conversation with a connected network device. And these Actions? They alternate between type "send" and "match", maybe not in their original Phrasebook definition, but certainly by the time they're actually used. No cap. ✨

  • If the first Action is of type "send", then the ActionSet is a normal sequence of "send a command" then "match a response", perhaps repeated. Very demure, very mindful. πŸ“¨βž‘οΈπŸ“©
  • If the first Action is of type "match", then the ActionSet represents a "continuation", which is the method of dealing with paged output. The plot twist! 😭

πŸ’– INTERFACE πŸ’–

πŸŽ€ default_continuation

An ActionSet ("match" then "send") which will be available for use on all commands sent from this ActionSet. It's an alternative to explicitly describing the Continuation sequence within the Phrasebook. Iconic option honestly. πŸ‘‘

πŸŽ€ current_match

A stash for the current Prompt (regular expression reference) which Net::CLI::Interact expects to see after each command. This gets passed into the constructor and is used when padding Match Actions into the ActionSet (peep "execute", down below πŸ‘‡).

πŸŽ€ clone

Returns a new ActionSet which is a shallow clone of the existing one. All the reference based slots will share data, but you can add (for example) a "current_match" without affecting the original ActionSet. Used when preparing to execute an ActionSet which has been retrieved from the Phrasebook. Copy-paste but make it ✨intentional✨.

πŸŽ€ apply_params

Accepts a list of parameters which will be used when "sprintf" is called on each Send Action in the set. You must supply sufficient parameters as a list for all Send Actions in the set, and they will be popped off and stashed with the Action(s) according to how many are required. So like, count your params bestie, don't be out here under-supplying 😀

πŸŽ€ register_callback

Allows the Transport to be registered such that when the ActionSet is executed, commands are sent to the registered callback subroutine. May be called more than once, and on execution each of the callbacks will be run, in turn and in order. Queue energy. πŸšΆβ€β™€οΈπŸšΆβ€β™€οΈπŸšΆβ€β™€οΈ

πŸŽ€ execute

The business end of this class πŸ”₯ β€” where the sequence of Actions is prepared for execution and then control is passed to the Transport. This process is split into a number of phases:

⭐ Pad "send" with "match"

The Phrasebook allows missing out of the Match statements between Send statements, when they're expected to be the same as the "current_match". This phase inserts Match statements to restore a complete ActionSet definition. Filling in the blanks, we love to see it. 🧚

⭐ Forward "continuation" to "match"

In the Phrasebook a user defines a Continuation ("match", then "send") following a Send statement (because it deals with the response to the sent command). However they are actually used by the Match, as it's the Match which captures output. πŸ‘€

This phase copies Continuation ActionSets from Send statements to following Match statements in the ActionSet. It also performs a similar action using the "default_continuation" if one is set and there's no existing Continuation configured. Handing off the aux cord, respectfully. 🎧

⭐ Callback(s)

Here the registered callbacks are executed (i.e. data is sent to the Transport). It's giving relay race. πŸƒβ€β™€οΈπŸ’¨

⭐ Marshall Responses

Finally, responses which are stashed in the Match Actions are copied back to the Send actions, as more logically they are responses to commands sent. The ActionSet is now ready for access to retrieve the "last_response" from the device. The circle is complete, the vibes are immaculate. πŸ’«


🌈 COMPOSITION 🌈

See the following for further interface details:

  • Net::CLI::Interact::Role::Iterator

bestie reminder: this whole thing is internal machinery, so don't come for me if you poke it and it does internal machinery things πŸ™ˆ

okay that's the page!! tysm for reading, ily, drink some water πŸ’–βœ¨

this absolute classic was served to you by perl v5.36.0, dated 2023-10-28, and delivered by Net::CLI::Interact::ActionSet(3pm) β€” periodt. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from