Compile a shell command
@param string $command
@param array $params
@return string
770469
protected static function _compileCommand($command,array $params){
        $s = $w = [];
        foreach ($params as $p) {
            if ($p instanceof static) {
              $s[] = '$('.$p->getShellCommand().')';
            } else if (is_array($p)) foreach ($p as $key => $value) {
                if(is_numeric($key)){
                  $w[] = '--'.$value;
                } else {
                  if(is_bool($value)){
                     if($value) $w[] = '--'.$key;
                  } else {
                    $w[] = '--'.$key.'='.escapeshellarg($value);
                  }
                }
            } else {
              $s[] = $p;
            }
        }
        return trim(
            '/usr/bin/env '.$command.' '.implode(' ',array_merge($w,$s))
        );
    }
419878
protected function executeCommand(
        $command,
        array $parameters = []
    ) {
        $environment = $this
            ->application
            ->getKernel()
            ->getEnvironment();

        $this
            ->application
            ->run(new ArrayInput(array_merge(
                [
                    'command'          => $command,
                    '--no-interaction' => true,
                    '--env'            => $environment,
                    '--quiet'          => true,
                ], $parameters
            )));

        return $this;
    }
722623
public static function build($command, array $args = []): string
    {
        $stringArgs = [];
        $realCommand = $command;

        if (count($args) > 0) {
            foreach ($args as $key => $value) {
                $value = trim($value);
                $key = trim($key);

                if (strpos($key, '-') !== 0) {
                    $key = strlen($key) === 1 ? '-' . $key : '--' . $key;
                }

                if (strlen($value) > 0) {
                    $stringArgs[] = $key . '="' . addcslashes($value, '"') . '"';
                } else {
                    $stringArgs[] = $key;
                }
            }
        }

        if (count($stringArgs)) {
            $realCommand = $command . ' ' . implode(' ', $stringArgs);
        }

        return $realCommand;
    }
1312647
public function drush($command, array $arguments = array(), array $options = array()) {
    $arguments = implode(' ', $arguments);

    // Disable colored output from drush.
    if (isset(static::$isLegacyDrush) && static::$isLegacyDrush) {
      $options['nocolor'] = TRUE;
    }
    else {
      $options['no-ansi'] = NULL;
    }
    $string_options = $this->parseArguments($options);

    $alias = isset($this->alias) ? "@{$this->alias}" : '--root=' . $this->root;

    // Add any global arguments.
    $global = $this->getArguments();

    $process = new Process("{$this->binary} {$alias} {$string_options} {$global} {$command} {$arguments}");
    $process->setTimeout(3600);
    $process->run();

    if (!$process->isSuccessful()) {
      throw new \RuntimeException($process->getErrorOutput());
    }

    // Some drush commands write to standard error output (for example enable
    // use drush_log which default to _drush_print_log) instead of returning a
    // string (drush status use drush_print_pipe).
    if (!$process->getOutput()) {
      return $process->getErrorOutput();
    }
    else {
      return $process->getOutput();
    }

  }
623795
def invoke(command, params={})
      command_string = compile_command(command, params)
      output_command(command_string)
      execute(command_string, params)
    end
639642
public function build($command)
    {
        return sprintf(
            '%s %s/%s %s --env=%s --no-debug',
            PhpUtils::getPhp(),
            $this->consoleDir,
            'console',
            $command,
            $this->environment
        );
    }
245337
private function buildCommand($command, $argument)
    {
        $command = sprintf($command, $argument);
        $this->output->writeln(
            'Calling following command:' . "\n" . $command,
            OutputInterface::VERBOSITY_DEBUG
        );

        return $command;
    }
562619
public function command($command, array $parameters = [])
    {
        if (class_exists($command)) {
            $command = Container::getInstance()->make($command)->getName();
        }

        return $this->exec(
            Application::formatCommandString($command), $parameters
        );
    }
563235
private function commands($params)
    {
        if (is_array($params)) {
            $param = '';
            $i = 0;
            $arrCount = count($params);

            foreach ($params as $key => $value) {
                $param .= $value;

                $comma = ($i < $arrCount - 1) ? ',' : '';

                $param .= $comma;

                $i++;
            }
        }

        if (is_string($params)) {
            $param = $params;
        }

        return $param;
    }
594619
public function command(string $sql, array $params = [])
    {
        return $this->execute($this->prepare($sql, $params));
    }
1017823
public function getProcessByCommand(string $command) : Process {
        if( ! array_key_exists($command, $this->processes) ) {
            $this->watch($command);
        }

        foreach($this->getWatchedProcesses() as $process) {
            if($process->getCommand() === $command) {
                return $process;
            }
        }
    }
938726
public function getCommand($command, $aliases = true)
    {
        if (array_key_exists($command, $this->commands)) {
            return $this->commands[$command];
        }

        if (array_key_exists($command, $this->aliases) && $aliases) {
            return $this->commands[$this->aliases[$command]];
        }
    }
888016
protected function exec($command, $arguments = [], $options = [])
    {
        $arguments = implode(' ', (array) $arguments);
        $options   = implode(' ', (array) $options);

        $command = sprintf('%s %s %s', $command, $arguments, $options);

        $this->out('>> ' . $command);

        if ($this->io->getOption('dry-run')) {
            return '';
        }

        $return = exec(trim($command), $this->lastOutput, $this->lastReturn);

        $this->out($return);
    }
1098188
private function executeCommand ($params)
    {
        array_shift($params);
        $command = ucfirst($params[0]);
        $command_dir = LIB.'/'.APP.'/Commands';

        // コマンドクラスのパスを取得する
        $read_paths = array($command_dir, dirname(__FILE__).'/Command/Provision');
        $command_path = false;
        foreach ($read_paths as $read_path) {
            if (file_exists($read_path.'/'.$command.'.php')) {
                $command_path = $read_path.'/'.$command.'.php';
            }
        }

        // コマンドクラスの有無を確認する
        if ($command_path === false) {
            throw new \InvalidArgumentException(sprintf('%s command is not found!', $command));
        }

        // コマンドの実行
        require_once $command_path;
        $class = new $command;
        $class->execute($params);
    }
225009
protected function generateCommandUrl(string $command, array $parameters = [])
    {
        $query = '';
        if (!empty($parameters)) {
            $query = '?' . http_build_query($parameters);
        }

        return $this->ssoServerUrl . '/sso/' . $command . $query;
    }
790919
protected function resolveCommand($command, array $parameters): CommandInterface
	{
		if($command instanceof CommandInterface)
		{
			return $command;
		}

		return $this->container->get($command, $parameters);
	}
752911
public function createCommand($sql = null, $params = [])
    {
        $command = new Command([
            'db' => $this,
            'sql' => $sql,
        ]);

        return $command->bindValues($params);
    }