@param OutputInterface $output
@param $name
@param array $args

@return $this

@throws \RuntimeException
327213
protected function executeCommand(OutputInterface $output, $name, $args = [])
    {
        array_unshift($args, 'internal');

        $return = $this->getApplication()->find($name)->run(new ArrayInput($args), $output);

        if (0 !== $return) {
            throw new \RuntimeException(sprintf("An error occured when executing command '%s'", $name), 30);
        }

        return $this;
    }
631036
public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        $this->initializeTabCompletion();

        if ($input === null && !isset($_SERVER['argv'])) {
            $input = new ArgvInput([]);
        }

        if ($output === null) {
            $output = $this->config->getOutput();
        }

        try {
            return parent::run($input, $output);
        } catch (\Exception $e) {
            $this->writeException($e);
        }

        return 1;
    }
1239096
public function setOutput(\Parable\Http\Output\OutputInterface $output)
    {
        $this->output = $output;
        $this->output->init($this);
        return $this;
    }
227191
private function generateOutput(InputInterface $input): OutputInterface
    {
        return new Output(
            $this->name,
            array_merge(
                $this->evaluateInputExports($input),
                $this->generateOutputParams($input)
            )
        );
    }
714524
public function runCommand($command, $parameters = array(), OutputInterface $output = null)
    {
        $parameters = array_merge(
            array('command' => $command),
            $this->getDefaultParameters(),
            $parameters
        );

        $this->getApplication()->setAutoExit(false);
        $exitCode = $this->getApplication()->run(new ArrayInput($parameters), $output ?: new NullOutput());

        if (1 === $exitCode) {
            throw new \RuntimeException('This command terminated with a permission error');
        }

        if (0 !== $exitCode) {
            $this->getApplication()->setAutoExit(true);

            $errorMessage = sprintf('The command terminated with an error code: %u.', $exitCode);
            $this->output->writeln("<error>$errorMessage</error>");
            $exception = new \Exception($errorMessage, $exitCode);

            throw $exception;
        }

        return $this;
    }
1205123
public static function create($name, ...$args)
    {
        $name = static::getClass($name);

        $class = static::findClass($name);

        if ($class) {
            return static::createObject($class, ...$args);
        }

        return null;
    }
555798
protected function invokeCommand($command_name, array $args = []) {
    $this->invokeDepth++;

    if (!$this->isCommandDisabled($command_name)) {
      /** @var \Acquia\Blt\Robo\Application $application */
      $application = $this->getContainer()->get('application');
      $command = $application->find($command_name);

      $input = new ArrayInput($args);
      $input->setInteractive($this->input()->isInteractive());
      $prefix = str_repeat(">", $this->invokeDepth);
      $this->output->writeln("<comment>$prefix $command_name</comment>");
      $exit_code = $application->runCommand($command, $input, $this->output());
      $this->invokeDepth--;

      // The application will catch any exceptions thrown in the executed
      // command. We must check the exit code and throw our own exception. This
      // obviates the need to check the exit code of every invoked command.
      if ($exit_code) {
        throw new BltException("Command `$command_name {$input->__toString()}` exited with code $exit_code.");
      }
    }
  }
571362
private function createDB(OutputInterface $output)
    {
        $output->write('> Loading the schema of the DB', true);

        $arguments = [
            'command' => 'doctrine:schema:update',
            '--force' => true,
        ];

        $input = new ArrayInput($arguments);

        return $this->getApplication()->run($input);
    }
355616
public function invokeMethod($object, $name, array $args = [])
    {
        $method = new ReflectionMethod($object, $name);
        $method->setAccessible(true);

        if (empty($args)) {
            return $method->invoke($object);
        }

        return $method->invokeArgs($object, $args);
    }
1177449
protected function execute(InputInterface $input, OutputInterface $output)
  {
    $this->_input = $input;
    $this->_output = $output;

    $params = array_values($input->getArguments());
    //Strip off the command name
    array_shift($params);

    //Call the execute command with $input and $output as the first args
    if(method_exists($this, 'executeCommand'))
    {
      array_unshift($params, $input, $output);
      return $this->executeCommand(...$params);
    }

    //Call the process method, without $input and $output
    if(method_exists($this, 'process'))
    {
      return $this->process(...$params);
    }

    throw new \RuntimeException(
      "Your command must contain one of the following methods:\n" .
      "process()\n" .
      'executeCommand(InputInterface $input, OutputInterface $output)' . "\n",
      500
    );
  }
31636
public function exec($name, $args = '', $returnExitCode = false)
    {
        return $this->take('binaries')->execBinary($name, $args, $returnExitCode);
    }
1124428
public function callMacro(string $name, array $args)
    {
        if (isset($this->macros[$name])) {
            return call_user_func_array($this->macros[$name], $args);
        }
        throw new RuntimeException('There is no macro with the given name "'.$name.'" to call');
    }
389745
public function executecommandFromName(InputInterface $input, OutputInterface $output, $commandNames, array $arguments, array $options, Config $config, ConfigService $s)
    {
        $silent = false;

        if ('?' === $commandNames{0}) {
            $silent = true;
            $commandNames = substr($commandNames, 1);
        }

        $this->executeHooks($input, $output, ':before', $config, $s);

        foreach (explode('+', $commandNames) as $_commandNames) {
            $exceptions = [];
            foreach (explode('~', $_commandNames) as $commandName) {
                $commandName = strtolower($commandName);
                try {
                    $command = $this->getCommand($commandName, $config);

                    if (method_exists($command, 'setConfigService')) {
                        $command->setConfigService($s);
                    }

                    if (method_exists($command, 'setOutput')) {
                        $command->setOutput($output);
                    }

                    if (method_exists($command, 'setInput')) {
                        $command->setInput($input);
                    }

                    if (method_exists($command, 'setConfig')) {
                        $command->setConfig($config);
                    }

                    $this->executeHooks($input, $output, $commandName.':before', $config, $s);
                    if (method_exists($command, 'execute')) {
                        $command->execute($arguments, $options);
                    } elseif (method_exists($command, '__invoke')) {
                        $command($arguments, $options);
                    } else {
                        $this->executeHooks($input, $output, $commandName.':failure', $config, $s);
                        throw new \RuntimeException(sprintf("Command '%s' is not executable", $commandName), 43);
                    }
                    $this->executeHooks($input, $output, $commandName.':after', $config, $s);
                } catch (\Exception $e) {
                    $exceptions[] = ['command' => $commandName, 'exception' => $e];
                }
            }
            if (count($exceptions)) {
                if ($silent) {
                    return $this;
                }

                $this->executeHooks($input, $output, ':failure', $config, $s);

                throw $exceptions[0]['exception'];
            }
        }

        $this->executeHooks($input, $output, ':after', $config, $s);

        return $this;
    }
223427
public function executeCommand(array $args, OutputInterface $output, $message)
    {
        $name = $args[0];
        $cmd = $this->getCmd($args);

        $output->writeln('');
        $output->writeln(
            sprintf(
                '<info>Running %s</info>',
                $name
            )
        );

        $output->writeln(
            sprintf(
                '<comment>%s</comment>',
                $cmd
            )
        );

        $this->process->setCommandLine($cmd);
        $this->process->run(
            function ($type, $buffer) use ($output, $cmd) {
                if (Process::ERR === $type) {
                    $output->writeln(
                        sprintf(
                            '<error>%s</error>',
                            $buffer
                        )
                    );
                } else {
                    $output->writeln(
                        sprintf(
                            '<comment>%s</comment>',
                            $buffer
                        )
                    );
                }
            }
        );

        if (!$this->process->isSuccessful()) {
            throw new \RuntimeException($message . '<error>' . $this->process->getErrorOutput() . '</error>');
        }
    }
1164701
protected function write(OutputInterface $output, array $result = null)
    {
        if ($result === null) {
            return;
        }

        foreach ($result as $label => $items) {
            $names = \array_map([$this, 'formatItemName'], $items);
            $output->writeln(\sprintf('<strong>%s</strong>: %s', $label, \implode(', ', $names)));
        }
    }
232500
public static function enable_log($name,$output=false){
		LogMaster::$_log=$name;
		LogMaster::$_output=$output;
		if ($name){
			set_error_handler(array("LogMaster","error_log"),E_ALL);
			set_exception_handler(array("LogMaster","exception_log"));
			LogMaster::log("\n\n====================================\nLog started, ".date("d/m/Y h:i:s")."\n====================================");
		}
	}
854520
public function setOutput(OutputInterface $output)
    {
        $this->output = $output;
        $this->stdErr = $output instanceof ConsoleOutputInterface
            ? $output->getErrorOutput()
            : $output;
    }