Ferreteria/v0.6/clade/IO/Aspect/Connx/Plug/Shell

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | IO‎ | Aspect‎ | Connx‎ | Plug
Jump to navigation Jump to search
clade: IO\Aspect\Connx\Plug\Shell
Clade Family
Plug Shell

Local
Remote

Clade Aliases
Alias Clade
BufferIface IO\Aspect\Connx\Buffer
MemBuffClass IO\Aspect\Connx\Buffer\InMem
Base* [ca,i] IO\Aspect\Connx\Plug
ProcIface IO\Aspect\Connx\Process
SelfIface IO\Aspect\Connx\Plug\Shell
Subpages

About

  • PURPOSE: abstraction of a command-shell connection
    • ...so that we can encapsulate the idea of a tunnel
    • ...but DB Connections will treat remote the same as local.

History

  • 2024-10-31 started
  • 2024-11-19 moved from [WFe]Config\Def\Connex -> [WFe]IO\Connx\Shell as part of Def/actor integration
  • 2025-05-27 moved from [WFe]IO\Connx -> [WFe]IO\Aspect\Connx
  • 2025-06-04 moved from [WFe]IO\Aspect\Connx -> [WFe]IO\Aspect\Connx\Plug

Pages

Code

as of 2025-10-31

interface iShell extends BaseIface {
    // LIFECYCLE
    function Open() : ActionIface;
    function Shut() : ActionIface;
    // OUTPUT
    #{I} function DescribeInline() : string;
}
abstract class caShell extends BaseClass implements SelfIface {

    // ++ OBJECTS ++ //

    protected function NewAction() : ActionIface { return new ($this->ActionClass()); }

    // -- OBJECTS -- //
    // ++ ACTION ++ //

    /**
     * ACTION: Sends a command, buffers the response, closes the command process
     * HISTORY:
     *  2024-11-24 created. This is experimental; if it works,
     *    this kind of thing should probably be encapsulated in its own class.
     *  2024-11-25 moved from shell/Secure to Shell
     *  2025-03-21 moved core code from Shell to Process::Run(); this now calls that.
     */
    public function DoCommand(string|array $saCmd, BufferIface $oBuff, ?CommOpIface $oAct=NULL) : CommOpIface {
        $oProc = ProcClass::FromCommand($saCmd);
        $oProc->SetRecvBuff($oBuff);
        if (is_null($oAct)) {
            $oAct = $this->NewAction();
        }
        $oProc->SetOpStator($oAct);

        return $oProc->Run();
    }
    public function OpenProcess(string|array $saCmd) : ProcIface {
        $oProc = ProcClass::FromCommand($saCmd);
        $oAct = $this->NewAction();
        $oProc->SetOpStator($oAct);
        return $oProc;
    }

    // -- ACTION -- //
}