public function action($name)
    {
        $command = '\\App\\Consoles\\'.ucfirst($name).'ConsoleCommand';
        $command = class_exists($command) ? $command : '\\Micro\\Cli\\Consoles\\'.ucfirst($name).'ConsoleCommand';

        if (!class_exists($command)) {
            throw new Exception('Command `'.$name.'` not found');
        }

        /** @var ConsoleCommand $command */
        $command = new $command();
        $command->execute();

        $response = (new ResponseInjector)->build();
        $response = $response->withHeader('status', (string)(int)$command->result);

        $stream = $response->getBody();
        $stream->write($command->message);

        return $response->withBody($stream);
    }
public function action($name)
    {
        $command = '\\App\\Consoles\\'.ucfirst($name).'ConsoleCommand';
        $command = class_exists($command) ? $command : '\\Micro\\Cli\\Consoles\\'.ucfirst($name).'ConsoleCommand';

        if (!class_exists($command)) {
            throw new Exception('Command `'.$name.'` not found');
        }

        /** @var ConsoleCommand $command */
        $command = new $command();
        $command->execute();

        $response = (new ResponseInjector)->build();
        $response = $response->withHeader('status', (string)(int)$command->result);

        $stream = $response->getBody();
        $stream->write($command->message);

        return $response->withBody($stream);
    }
public function action ( $ name ) { $ command = '\\App\\Consoles\\' . ucfirst ( $ name ) . 'ConsoleCommand' ; $ command = class_exists ( $ command ) ? $ command : '\\Micro\\Cli\\Consoles\\' . ucfirst ( $ name ) . 'ConsoleCommand' ; if ( ! class_exists ( $ command ) ) { throw new Exception ( 'Command `' . $ name . '` not found' ) ; } /** @var ConsoleCommand $command */ $ command = new $ command ( ) ; $ command -> execute ( ) ; $ response = ( new ResponseInjector ) -> build ( ) ; $ response = $ response -> withHeader ( 'status' , ( string ) ( int ) $ command -> result ) ; $ stream = $ response -> getBody ( ) ; $ stream -> write ( $ command -> message ) ; return $ response -> withBody ( $ stream ) ; }
Run action of console command by name

@access public

@param string $name Command name

@return ResponseInterface
@throws \RuntimeException|\InvalidArgumentException|Exception
Run action of console command by name