Run an Artisan console command by name.

@param  string  $command
@param  array  $parameters
@param  \Symfony\Component\Console\Output\OutputInterface  $outputBuffer
@return int

@throws \Symfony\Component\Console\Exception\CommandNotFoundException
493726
public function call($command, array $parameters = [], $outputBuffer = null)
    {
        $this->bootstrap();

        return $this->getArtisan()->call($command, $parameters, $outputBuffer);
    }
932122
private function executeRest($command, $parameters = array())
    {

        $result = $this->restClient->execute($command);

        if (isset($result['code']) && $result['code'] === 0) {
            return $result;
        }

        throw new Exception(
            "There was an error with the Rest call " .
            $command->getName() .
            PHP_EOL .
            $result['code'] .
            ' : ' .
            $result['message'] .
            PHP_EOL .
            print_r($result['errors'], true) .
            PHP_EOL .
            'Parameters : ' .
            print_r($parameters, true) .
            PHP_EOL,
            $result['code']
        );

    }
628982
protected function runCommand(\Parable\Console\Command $command, array $parameters = [])
    {
        $parameter = new \Parable\Console\Parameter();
        $parameter->setParameters($parameters);

        $command->prepare($this->app, $this->output, $this->input, $parameter);

        return $command->run();
    }
364517
public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        if (null === $input) {
            // rewrite the input for single command usage
            $argv = $_SERVER['argv'];
            $scriptName = array_shift($argv);
            array_unshift($argv, 'lint');
            array_unshift($argv, $scriptName);
            $input = new ArgvInput($argv);
        }

        return parent::run($input, $output);
    }
1125669
public function execute(array $parameters = [])
    {
        if (!$this->isValid()) {
            throw new InvalidCommandExecutionException($this->commandName);
        }

        $parameters = \array_merge($this->commandParameters, $parameters);
        $command = new CommandToExecute($this->commandName, $parameters);

        return $this->commandExecutor->execute($command);
    }
301137
public function runCommand(Command $command, array $parameters = [], OutputInterface $output = null)
    {
        $parameters['command'] = $command->getName();
        $input = new ArrayInput($parameters);

        if ($output === null) {
            $output = new NullOutput();
        }

        $command->setApplication(new SymfonyConsoleApplication());

        return $command->run($input, $output);
    }
470055
public static function executeCommand($commandName, array $commandParameters) {
        if (isset(self::$commands[$commandName])) {
            $commandAction = self::$commands[$commandName];
        }
        else {
            $commandsBaseNamespace = get_property("cli.commands_base_namespace");
            if (!empty($commandsBaseNamespace)) {
                $commandAction = $commandsBaseNamespace;
                $commandTokens = explode(".", $commandName);
                $commandTokensSize = sizeof($commandTokens);
                if ($commandTokensSize > 1) {
                    for ($i = 0; $i < $commandTokensSize - 1; $i++) {
                        $commandToken = $commandTokens[$i];
                        $commandAction .= '\\';
                        $commandAction .= str_replace(' ', '', ucwords(str_replace('_', ' ', $commandToken)));
                    }
                }
                $commandAction .= '\\';
                $commandAction .= str_replace(' ', '', ucwords(str_replace('_', ' ', $commandTokens[$commandTokensSize - 1])));
                $commandAction .= get_property("cli.commands_suffix", "Command");
            }
            else {
                throw new CommandNotFoundException("Command \"$commandName\" not found !!");
            }
        }

        $result = null;
        if (is_string($commandAction) && class_exists($commandAction) && is_subclass_of($commandAction, Command::class)) {
            if (!isset(self::$commandInstances[$commandAction])) {
                self::$commandInstances[$commandAction] = new $commandAction;
            }
            self::$commandInstances[$commandAction]->handle($commandParameters);
        }
        else  {
            try {
                get_app()->execute($commandAction, $commandParameters);
            }
            catch (ActionNotFoundException $ex) {
                throw new CommandNotFoundException("Command \"$commandName\" not found !!. Command class \"$commandAction\" not found !! ", 0, $ex);
            }
        }
        return $result;
    }
1062771
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $cmd        = $input->getArgument('cmd');
        $process    = $input->getArgument('server');

        $server = new Server(
            Config::get('name'),
            $process
        );

        $server->$cmd();
    }
184355
public function command($command, array $parameters = [])
    {
        if (class_exists($command)) {
            $command = (new $command)->getName();
        }

        return $this->exec(
            Application::formatCommandString($command), $parameters
        );
    }
1229070
public function executeNanbando($command, array $parameter, callable $callback = null)
    {
        $this->login();

        $parameterString = [];
        foreach ($parameter as $key => $value) {
            if (!is_array($value)) {
                $value = [$value];
            }

            foreach ($value as $item) {
                $parameterString[] = trim((is_string($key) ? $key . ' ' : '') . $item);
            }
        }

        return $this->execute(
            sprintf('%s %s %s', $this->executable, $command, implode(' ', $parameterString)),
            $callback
        );
    }
154622
public function run($command, array $parameters = [])
    {
        if (\is_string($command) && \count($parameters)) {
            $command .= ' ' . $this->compileParameters($parameters);
        }

        $this->events[] = $event = new Event($this->id(), $command);

        return $event;
    }
379024
public function runCommand($command, array $parameters = [], $silent = false)
    {
        $class = $this->make($command);
        if ($class instanceof Command) {
            if ($silent) {
                $class->setSilent(true);
            }
            $class->run($parameters);
        } else {
            throw new ConsoleException('Class has to be a instance of '.Command::class.'!');
        }
    }
1113051
private function executeCommand(string $command, array $parameters = []): self
    {
        if (! $this->progressBar->getProgress()) {
            $this->progressBar->start();
        }

        $result = $this->call($command, $parameters);
        if ($result) {
            $parameters = http_build_query($parameters, '', ' ');
            $parameters = str_replace('%5C', '/', $parameters);
            $this->alert("An error has occurred. The '{$command} {$parameters}' command was not executed");
        }

        $this->progressBar->advance();

        // Visually slow down the installation process so that the user can read what's happening
        usleep(350000);

        return $this;
    }
757512
public static function exec($command, array $params = array(), $mergeStdErr=true)
    {
        if (empty($command)) {
            throw new \InvalidArgumentException('Command line is empty');
        }

        $command = self::bindParams($command, $params);

        if ($mergeStdErr) {
            // Redirect stderr to stdout to include it in $output
            $command .= ' 2>&1';
        }

        exec($command, $output, $code);

        if (count($output) === 0) {
            $output = $code;
        } else {
            $output = implode(PHP_EOL, $output);
        }

        if ($code !== 0) {
            throw new CommandException($command, $output, $code);
        }

        return $output;
    }
975954
private function run($command)
    {
        $application = $this->createApplication();
        $application->setAutoExit(false);

        $this->applicationTester = new ApplicationTester($application);

        $this->outputFile = tempnam('.', 'phpeg');

        return $this->applicationTester->run(array(
            'command' => $command,
            'input-file' => $this->inputFile,
            'output-file' => $this->outputFile
        ));
    }
1215426
public function command($method, array $parameters = [])
    {
        $start = microtime(true);

        $result = $this->client->{$method}(...$parameters);

        $time = round((microtime(true) - $start) * 1000, 2);

        if (isset($this->events)) {
            $this->event(new CommandExecuted($method, $parameters, $time, $this));
        }

        return $result;
    }
1104983
public void executeCommand(String command, List<String> parameters) {

        if (null == command) {
            return;
        }

        if (m_echo) {
            // echo the command to STDOUT
            m_out.print(command);
            for (int i = 0; i < parameters.size(); i++) {
                m_out.print(" '");
                m_out.print(parameters.get(i));
                m_out.print("'");
            }
            m_out.println();
        }

        // prepare to lookup a method in CmsObject or CmsShellCommands
        boolean executed = false;
        Iterator<CmsCommandObject> i = m_commandObjects.iterator();
        while (!executed && i.hasNext()) {
            CmsCommandObject cmdObj = i.next();
            executed = cmdObj.executeMethod(command, parameters);
        }

        if (!executed) {
            // method not found
            m_out.println();
            StringBuffer commandMsg = new StringBuffer(command).append("(");
            for (int j = 0; j < parameters.size(); j++) {
                commandMsg.append("value");
                if (j < (parameters.size() - 1)) {
                    commandMsg.append(", ");
                }
            }
            commandMsg.append(")");

            m_out.println(m_messages.key(Messages.GUI_SHELL_METHOD_NOT_FOUND_1, commandMsg.toString()));
            m_out.println(m_messages.key(Messages.GUI_SHELL_HR_0));
            ((CmsShellCommands)m_shellCommands).help();
        }
    }