public function shellCommand()
    {
        if (!function_exists('readline_read_history')) {
            $this->outputLine('Interactive Shell is not available on this system!');
            $this->quit(1);
        }
        $subProcess = false;
        $pipes = [];

        $historyPathAndFilename = getenv('HOME') . '/.flow_' . md5(FLOW_PATH_ROOT);
        readline_read_history($historyPathAndFilename);
        readline_completion_function([$this, 'autocomplete']);

        echo "Flow Interactive Shell\n\n";

        while (true) {
            $commandLine = readline('Flow > ');
            if ($commandLine === '') {
                echo "\n";
                break;
            }

            readline_add_history($commandLine);
            readline_write_history($historyPathAndFilename);

            $request = $this->requestBuilder->build($commandLine);
            $response = new Response();
            $command = $request->getCommand();

            if ($request === false || $command->getCommandIdentifier() === false) {
                echo "Bad command\n";
                continue;
            }
            if ($this->bootstrap->isCompiletimeCommand($command->getCommandIdentifier())) {
                $this->dispatcher->dispatch($request, $response);
                $response->send();
                if (is_resource($subProcess)) {
                    $this->quitSubProcess($subProcess, $pipes);
                }
            } else {
                if (is_resource($subProcess)) {
                    $subProcessStatus = proc_get_status($subProcess);
                    if ($subProcessStatus['running'] === false) {
                        proc_close($subProcess);
                    }
                };
                if (!is_resource($subProcess)) {
                    list($subProcess, $pipes) = $this->launchSubProcess();
                    if ($subProcess === false || !is_array($pipes)) {
                        echo "Failed launching the shell sub process for executing the runtime command.\n";
                        continue;
                    }
                    $this->echoSubProcessResponse($pipes);
                }

                fwrite($pipes[0], $commandLine . "\n");
                fflush($pipes[0]);
                $this->echoSubProcessResponse($pipes);

                if ($command->isFlushingCaches()) {
                    $this->quitSubProcess($subProcess, $pipes);
                }
            }
        }

        if (is_resource($subProcess)) {
            $this->quitSubProcess($subProcess, $pipes);
        }

        echo "Bye!\n";
    }
public function shellCommand()
    {
        if (!function_exists('readline_read_history')) {
            $this->outputLine('Interactive Shell is not available on this system!');
            $this->quit(1);
        }
        $subProcess = false;
        $pipes = [];

        $historyPathAndFilename = getenv('HOME') . '/.flow_' . md5(FLOW_PATH_ROOT);
        readline_read_history($historyPathAndFilename);
        readline_completion_function([$this, 'autocomplete']);

        echo "Flow Interactive Shell\n\n";

        while (true) {
            $commandLine = readline('Flow > ');
            if ($commandLine === '') {
                echo "\n";
                break;
            }

            readline_add_history($commandLine);
            readline_write_history($historyPathAndFilename);

            $request = $this->requestBuilder->build($commandLine);
            $response = new Response();
            $command = $request->getCommand();

            if ($request === false || $command->getCommandIdentifier() === false) {
                echo "Bad command\n";
                continue;
            }
            if ($this->bootstrap->isCompiletimeCommand($command->getCommandIdentifier())) {
                $this->dispatcher->dispatch($request, $response);
                $response->send();
                if (is_resource($subProcess)) {
                    $this->quitSubProcess($subProcess, $pipes);
                }
            } else {
                if (is_resource($subProcess)) {
                    $subProcessStatus = proc_get_status($subProcess);
                    if ($subProcessStatus['running'] === false) {
                        proc_close($subProcess);
                    }
                };
                if (!is_resource($subProcess)) {
                    list($subProcess, $pipes) = $this->launchSubProcess();
                    if ($subProcess === false || !is_array($pipes)) {
                        echo "Failed launching the shell sub process for executing the runtime command.\n";
                        continue;
                    }
                    $this->echoSubProcessResponse($pipes);
                }

                fwrite($pipes[0], $commandLine . "\n");
                fflush($pipes[0]);
                $this->echoSubProcessResponse($pipes);

                if ($command->isFlushingCaches()) {
                    $this->quitSubProcess($subProcess, $pipes);
                }
            }
        }

        if (is_resource($subProcess)) {
            $this->quitSubProcess($subProcess, $pipes);
        }

        echo "Bye!\n";
    }
public function shellCommand ( ) { if ( ! function_exists ( 'readline_read_history' ) ) { $ this -> outputLine ( 'Interactive Shell is not available on this system!' ) ; $ this -> quit ( 1 ) ; } $ subProcess = false ; $ pipes = [ ] ; $ historyPathAndFilename = getenv ( 'HOME' ) . '/.flow_' . md5 ( FLOW_PATH_ROOT ) ; readline_read_history ( $ historyPathAndFilename ) ; readline_completion_function ( [ $ this , 'autocomplete' ] ) ; echo "Flow Interactive Shell\n\n" ; while ( true ) { $ commandLine = readline ( 'Flow > ' ) ; if ( $ commandLine === '' ) { echo "\n" ; break ; } readline_add_history ( $ commandLine ) ; readline_write_history ( $ historyPathAndFilename ) ; $ request = $ this -> requestBuilder -> build ( $ commandLine ) ; $ response = new Response ( ) ; $ command = $ request -> getCommand ( ) ; if ( $ request === false || $ command -> getCommandIdentifier ( ) === false ) { echo "Bad command\n" ; continue ; } if ( $ this -> bootstrap -> isCompiletimeCommand ( $ command -> getCommandIdentifier ( ) ) ) { $ this -> dispatcher -> dispatch ( $ request , $ response ) ; $ response -> send ( ) ; if ( is_resource ( $ subProcess ) ) { $ this -> quitSubProcess ( $ subProcess , $ pipes ) ; } } else { if ( is_resource ( $ subProcess ) ) { $ subProcessStatus = proc_get_status ( $ subProcess ) ; if ( $ subProcessStatus [ 'running' ] === false ) { proc_close ( $ subProcess ) ; } } ; if ( ! is_resource ( $ subProcess ) ) { list ( $ subProcess , $ pipes ) = $ this -> launchSubProcess ( ) ; if ( $ subProcess === false || ! is_array ( $ pipes ) ) { echo "Failed launching the shell sub process for executing the runtime command.\n" ; continue ; } $ this -> echoSubProcessResponse ( $ pipes ) ; } fwrite ( $ pipes [ 0 ] , $ commandLine . "\n" ) ; fflush ( $ pipes [ 0 ] ) ; $ this -> echoSubProcessResponse ( $ pipes ) ; if ( $ command -> isFlushingCaches ( ) ) { $ this -> quitSubProcess ( $ subProcess , $ pipes ) ; } } } if ( is_resource ( $ subProcess ) ) { $ this -> quitSubProcess ( $ subProcess , $ pipes ) ; } echo "Bye!\n" ; }
Run the interactive Shell

The shell command runs Flow's interactive shell. This shell allows for
entering commands like through the regular command line interface but
additionally supports autocompletion and a user-based command history.

@return void
Run the interactive Shell