public function run(Command $command, OutputFormatter $formatter = null) : Result
    {
        $cmd = $this->processor->run($command->getCommand(), $command->getAcceptableExitCodes());

        if (!$cmd->isSuccessful()) {
            throw new RuntimeException(
                'Command failed:' . PHP_EOL
                . '  exit-code: ' . $cmd->getCode() . PHP_EOL
                . '  message:   ' . $cmd->getStdErr() . PHP_EOL,
                $cmd->getCode()
            );
        }

        $formatted = $formatter !== null ? $formatter->format($cmd->getStdOutAsArray()) : [];
        $result    = new Result($cmd, $formatted);

        return $result;
    }
public function run(Command $command, OutputFormatter $formatter = null) : Result
    {
        $cmd = $this->processor->run($command->getCommand(), $command->getAcceptableExitCodes());

        if (!$cmd->isSuccessful()) {
            throw new RuntimeException(
                'Command failed:' . PHP_EOL
                . '  exit-code: ' . $cmd->getCode() . PHP_EOL
                . '  message:   ' . $cmd->getStdErr() . PHP_EOL,
                $cmd->getCode()
            );
        }

        $formatted = $formatter !== null ? $formatter->format($cmd->getStdOutAsArray()) : [];
        $result    = new Result($cmd, $formatted);

        return $result;
    }
public function run ( Command $ command , OutputFormatter $ formatter = null ) : Result { $ cmd = $ this -> processor -> run ( $ command -> getCommand ( ) , $ command -> getAcceptableExitCodes ( ) ) ; if ( ! $ cmd -> isSuccessful ( ) ) { throw new RuntimeException ( 'Command failed:' . PHP_EOL . '  exit-code: ' . $ cmd -> getCode ( ) . PHP_EOL . '  message:   ' . $ cmd -> getStdErr ( ) . PHP_EOL , $ cmd -> getCode ( ) ) ; } $ formatted = $ formatter !== null ? $ formatter -> format ( $ cmd -> getStdOutAsArray ( ) ) : [ ] ; $ result = new Result ( $ cmd , $ formatted ) ; return $ result ; }
Execute a cli command.

@param  \SebastianFeldmann\Cli\Command                 $command
@param  \SebastianFeldmann\Cli\Command\OutputFormatter $formatter
@return \SebastianFeldmann\Cli\Command\Runner\Result
Execute a cli command .