Creates new instance of self, and passes it to new instance of CommandResult

@param string $command
@param bool $passThrough

@return CommandResultInterface
3968
public static function command(string $command, bool $passThrough = false): CommandResultInterface
    {
        return new CommandResult(
            new static(
                $command,
                $passThrough
            )
        );
    }
983842
public static function make(CommandInterface $command, ProcessOutputInterface $outputHandler = null)
    {
        return new Process($command, null, $outputHandler);
    }
599648
public function CLCommand($command, $exec = '')
    {
        $this->XMLWrapper = new XMLWrapper(array('encoding' => $this->getOption('encoding')), $this);

        $this->cpfErr = '0';
        $this->error = '';
        $this->errorText = '';

        $inputXml = $this->XMLWrapper->buildCommandXmlIn($command, $exec);

        // rexx and pase are the ways we might get data back.
        $expectDataOutput = in_array($exec, array('rexx', 'pase', 'pasecmd'));

        // if a PASE command is to be run, the tag will be 'sh'. Otherwise, 'cmd'.
        if ($exec == 'pase' || $exec == 'pasecmd') {
            $parentTag = 'sh';
        } else {
            $parentTag = 'cmd';
        }

        $this->VerifyPLUGName();

        // send the XML, running the command
        $outputXml = $this->sendXml($inputXml, false);

        // get status: error or success, with a real CPF error message, and set the error code/msg.
        $successFlag = $this->XMLWrapper->getCmdResultFromXml($outputXml, $parentTag);

        if ($successFlag) {
            $this->cpfErr = '0';
            $this->error = '';
        } else {
            $this->cpfErr = $this->XMLWrapper->getErrorCode();
            $this->error = $this->cpfErr; // ->error is ambiguous. Include for backward compat.
            $this->errorText = $this->XMLWrapper->getErrorMsg();
        }

        if ($successFlag && $expectDataOutput) {
            // if we expect to receive data, extract it from the XML and return it.
            $outputParamArray = $this->XMLWrapper->getRowsFromXml($outputXml, $parentTag);

            unset($this->XMLWrapper);
            return $outputParamArray;
        } else {
            // don't expect data. Return true/false (success);
            unset($this->XMLWrapper);
            return $successFlag;
        }
    }
869469
public function resolve(interfaces\commands\Command $command): interfaces\handlers\Handler
    {
        $commandClass = get_class($command);

        if (isset($this->handlers[$commandClass])) {
            $handler = $this->handlers[$commandClass];

            return is_object($handler) ? $handler : $this->createHandler($handler);
        }

        if ($command instanceof interfaces\commands\PlainCommand) {
            return $this->createHandler($this->plainCommandHandlerClassName);
        }

        $handlerClass = $commandClass . 'Handler';
        if (class_exists($handlerClass)) {
            return $this->createHandler($handlerClass);
        }

        $handlerClass = str_replace('\\commands\\', '\\handlers\\', $handlerClass);
        if (class_exists($handlerClass)) {
            return $this->createHandler($handlerClass);
        }

        throw new Exception("Could not terminate the handler of a command of type \"{$commandClass}\"");
    }
405730
public function addCommand(\Parable\Console\Command $command)
    {
        $command->prepare($this, $this->output, $this->input, $this->parameter);
        $this->commands[$command->getName()] = $command;
        return $this;
    }
266649
public function addCallbackCommand($command)
    {
        if (!is_object($command)) {
            if (!class_exists($command)) {
                throw new TelegramSDKException(
                    sprintf(
                        'Command class "%s" not found! Please make sure the class exists.',
                        $command
                    )
                );
            }

            if ($this->telegram->hasContainer()) {
                $command = $this->buildDependencyInjectedAnswer($command);
            } else {
                $command = new $command();
            }
        }

        if ($command instanceof CallbackCommandInterface) {

            /*
             * At this stage we definitely have a proper command to use.
             *
             * @var CallbackCommand $command
             */
            $this->commands[$command->getName()] = $command;

            return $this;
        }

        throw new TelegramSDKException(
            sprintf(
                'Command class "%s" should be an instance of "Telegram\Bot\Callback\CallbackCommandInterface"',
                get_class($command)
            )
        );
    }
375206
public function dispatch(Command $command, CommandCallback $callback = null)
    {
        $command = $this->intercept($command);

        $handler = $this->handlerRegistry->findCommandHandlerFor($command);

        $this->unitOfWork->start();
        $interceptorChain = new DefaultInterceptorChain($command, $this->unitOfWork, $handler, ...$this->handlerInterceptors);

        try {
            $result = $interceptorChain->proceed();
            if (null !== $callback) {
                $callback->onSuccess($result);
            }
        } catch (\Exception $exception) {
            $this->unitOfWork->rollback($exception);
            if (null !== $callback) {
                $callback->onFailure($exception);
            }

            throw $exception;
        }

        $this->unitOfWork->commit();

        return $result;
    }
1289995
public function execute($command, callable $next)
    {

        if ($command instanceof BackgroundCommand && !$command->isRunningInBackground()) {
            return $this->runProcess($command);
        }

        return $next($command);
    }
1026271
public function execute($command, callable $next)
    {
        if ($command instanceof FallbackCommand) {
            $command->message = new TextTemplate();
            $command->message->text = "Oops! I dont know wath you say.";
        }

        return $next($command);
    }
547734
protected function _commandNew(ControllerToolbarCommand $command)
    {
        if (empty($command->href))
        {
            $controller    = $this->getController();
            $identifier    = $controller->getIdentifier();
            $command->href = $controller->getView()->getRoute('component='.$identifier->package.'&view='.$identifier->name);
        }

        $command->icon = 'k-icon-plus';
    }
470124
public function callSilent($command, array $arguments = []) {
		$instance = $this->getApplication()->find($command);
		$arguments['command'] = $command;

		return $instance->run(new ArrayInput($arguments), new NullOutput);
	}
35265
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;
    }
1364043
public static function create(
        string $msg,
        int $exitCode,
        array $output,
        string $cmd, array
        $arguments = []
    ) : self {
        $e = new self($msg, $exitCode);

        $e->setOutput($output)
            ->setCmd($cmd)
            ->setArguments($arguments);

        return $e;
    }
1236718
protected function handle(CommandInterface $command)
	{
		if($command instanceof SelfHandlingCommandInterface)
		{
			return $command->handle();
		}

		$handler = $this->resolveCommandHandler($command);

		return $this->executeCommandHandler($handler, $command);
	}
254013
public function add($command)
    {
        if (is_string($command)) {
            $command = new $command($this->container);
        }

        if (!$command instanceof Console\Commands) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Argument 1 passed to %s must be an instance of %s, %s given',
                    __FUNCTION__,
                    Console\Commands::class,
                    get_class($command)
                )
            );
        }

        if (array_key_exists($command->name(), $this->commands)) {
            throw new \RuntimeException(
                sprintf('Command %s already registered', $command->name())
            );
        }

        $this->commands[$command->name()] = $command;

        return $this;
    }
550849
public function execute($command, callable $next)
    {
        // dev only
        if ($this->isDebug && $command->logs) {
            VarDumper::dump($command->logs);
        }

        return $next($command);
    }
927167
public static function create($commandToHandlerMap)
    {
        $handlerMiddleware = new CommandHandlerMiddleware(
            new ClassNameExtractor(),
            new InMemoryLocator($commandToHandlerMap),
            new HandleInflector()
        );

        $lockingMiddleware = new LockingMiddleware();

        return new CommandBus([$lockingMiddleware, $handlerMiddleware]);
    }