@param array $options
@param Branch|string $arg

@throws \RuntimeException
@return string
11727
public function revParse($arg = null, Array $options = array())
    {
        $this->clearAll();
        $this->addCommandName(self::GIT_REV_PARSE_COMMAND);
        // if there are options add them.
        if (! is_null($options)) {
            foreach ($options as $option) {
                $this->addCommandArgument($option);
            }
        }
        if (! is_null($arg)) {
            $this->addCommandSubject2($arg);
        }

        return $this->getCommand();
    }
91061
public function execute(array $args, array $options = [])
    {
        $this->bootstrap($args, $options);

        $seedSet = isset($options['seed']) ? $options['seed'] : $options['s'];

        $start = microtime(true);

        if (empty($seedSet)) {
            // run all the seed(ers)
            $this->getManager()->seed();
        } else {
            is_array($seedSet) || $seedSet = [$seedSet];
            // run seed(ers) specified in a comma-separated list of classes
            foreach ($seedSet as $seed) {
                $this->getManager()->seed(trim($seed));
            }
        }

        $end = microtime(true);

        Output::writeln('');
        Output::writeln(Colour::colour('All Done. Took ' . sprintf('%.4fs', $end - $start), Colour::GREEN));
    }
726391
public function execute(array $args = [], array $options = [])
    {
        $d     = new Service\DebugService();
        $infos = $d->describe();
        $max   = 0;

        foreach ($infos as $section => $data) {
            foreach ($data as $k => $v) {
                $len = strlen($k);
                $max = $max < $len ? $len : $max;
            }
        }

        foreach ($infos as $section => $data) {
            echo sprintf('[%s]', strtoupper($section)).PHP_EOL.PHP_EOL;
            foreach ($data as $k => $v) {
                echo sprintf(' %'.((int) $max).'s:  %s', ucwords(str_replace('_', ' ', $k)), is_array($v) ? join(' ', $v) : (is_bool($v) ? ($v ? 'true' : 'false') : $v)).PHP_EOL;
            }
            echo PHP_EOL;
        }
    }
365672
public function run(array $args = null) {
		$exec = escapeshellcmd($this->command);
		if ($args) {
			$exec .= " ". implode(" ", array_map("escapeshellarg", (array) $args));
		}
		
		if ($this->sudo) {
			$this->suExec(sprintf($this->sudo." 2>&1", $exec), $this->verbose);
		} elseif ($this->verbose) {
			ob_start(function($s) {
				$this->output .= $s;
				return $s;
			}, 1);
			passthru($exec, $this->status);
			ob_end_flush();
		} elseif ($this->verbose !== false /* !quiet */) {
			ob_start([$this, "progress"], 1);
			passthru($exec . " 2>&1", $this->status);
			ob_end_flush();
		} else {
			exec($exec ." 2>&1", $output, $this->status);
			$this->output = implode("\n", $output);
		}
		
		if ($this->status) {
			throw new Exception("Command {$exec} failed ({$this->status})");
		}

		return $this;
	}
679760
public function execute(array $args, array $options = [])
    {
        $this->bootstrap($args, $options);

        $version = isset($options['target']) ? $options['target'] : $options['t'];
        $date = isset($options['date']) ? $options['date'] : $options['d'];

        // run the migrations
        $start = microtime(true);
        if (null !== $date) {
            $this->getManager()->migrateToDateTime(new \DateTime($date));
        } else {
            $this->getManager()->migrate($version);
        }
        $end = microtime(true);

        Output::writeln('');
        Output::writeln(Colour::colour('All Done. Took ' . sprintf('%.4fs', $end - $start), Colour::CYAN));

        return 0;
    }
686082
public function execute(array $runtimeArgs)
    {
        if (null === $this->commandName)
        {
            throw new CommandNameNotSetException(self::class, __METHOD__);
        }

        return parent::execute($runtimeArgs);
    }
1150379
public function execute(array $args, array $options = [])
    {
        if (!isset($args[0])) {
            throw new \InvalidArgumentException('arg action must be input');
        }
        $action = explode('::', $args[0]);
        if (!class_exists($action[0])) {
            throw new \InvalidArgumentException('action not not found!');
        }

        if (isset($args[1])) {
            $frequency = abs(intval($args[1]));
        } else {
            $frequency = null;
        }
        ProcessManage::addTask($action, $frequency);
    }
976848
public function arg(string $arg): ProcessBuilder
    {
        if ($arg === '') {
            return $this;
        }

        $this->arguments[] = $arg;

        return $this;
    }
841911
public function execute($args)
    {
        self::$definedProps = new Properties();
        $this->searchForThis = null;

        // 1) First handle any options which should always
        // Note: The order in which these are executed is important (if multiple of these options are specified)

        if (in_array('-help', $args) || in_array('-h', $args)) {
            static::printUsage();

            return;
        }

        if (in_array('-version', $args) || in_array('-v', $args)) {
            static::printVersion();

            return;
        }

        if (in_array('-init', $args) || in_array('-i', $args)) {
            $key = array_search('-init', $args) ?: array_search('-i', $args);
            $path = isset($args[$key + 1]) ? $args[$key + 1] : null;

            self::init($path);

            return;
        }

        if (in_array('-diagnostics', $args)) {
            Diagnostics::doReport(new PrintStream(self::$out));

            return;
        }

        // 2) Next pull out stand-alone args.
        // Note: The order in which these are executed is important (if multiple of these options are specified)

        if (false !== ($key = array_search('-quiet', $args, true)) || false !== ($key = array_search(
            '-q',
            $args,
            true
        ))
        ) {
            self::$msgOutputLevel = Project::MSG_WARN;
            unset($args[$key]);
        }

        if (false !== ($key = array_search('-emacs', $args, true))
            || false !== ($key = array_search('-e', $args, true))
        ) {
            $this->emacsMode = true;
            unset($args[$key]);
        }

        if (false !== ($key = array_search('-verbose', $args, true))) {
            self::$msgOutputLevel = Project::MSG_VERBOSE;
            unset($args[$key]);
        }

        if (false !== ($key = array_search('-debug', $args, true))) {
            self::$msgOutputLevel = Project::MSG_DEBUG;
            unset($args[$key]);
        }

        if (false !== ($key = array_search('-silent', $args, true))
            || false !== ($key = array_search('-S', $args, true))
        ) {
            $this->silent = true;
            unset($args[$key]);
        }

        if (false !== ($key = array_search('-propertyfileoverride', $args, true))) {
            $this->propertyFileOverride = true;
            unset($args[$key]);
        }

        // 3) Finally, cycle through to parse remaining args
        //
        $keys = array_keys($args); // Use keys and iterate to max(keys) since there may be some gaps
        $max = $keys ? max($keys) : -1;
        for ($i = 0; $i <= $max; $i++) {
            if (!array_key_exists($i, $args)) {
                // skip this argument, since it must have been removed above.
                continue;
            }

            $arg = $args[$i];

            if ($arg == "-logfile") {
                try {
                    // see: http://phing.info/trac/ticket/65
                    if (!isset($args[$i + 1])) {
                        $msg = "You must specify a log file when using the -logfile argument\n";
                        throw new ConfigurationException($msg);
                    }

                    $logFile = new PhingFile($args[++$i]);
                    $out = new FileOutputStream($logFile); // overwrite
                    self::setOutputStream($out);
                    self::setErrorStream($out);
                    self::$isLogFileUsed = true;
                } catch (IOException $ioe) {
                    $msg = "Cannot write on the specified log file. Make sure the path exists and you have write permissions.";
                    throw new ConfigurationException($msg, $ioe);
                }
            } elseif ($arg == "-buildfile" || $arg == "-file" || $arg == "-f") {
                if (!isset($args[$i + 1])) {
                    $msg = "You must specify a buildfile when using the -buildfile argument.";
                    throw new ConfigurationException($msg);
                }

                $this->buildFile = new PhingFile($args[++$i]);
            } elseif ($arg == "-listener") {
                if (!isset($args[$i + 1])) {
                    $msg = "You must specify a listener class when using the -listener argument";
                    throw new ConfigurationException($msg);
                }

                $this->listeners[] = $args[++$i];
            } elseif (StringHelper::startsWith("-D", $arg)) {
                // Evaluating the property information //
                // Checking whether arg. is not just a switch, and next arg. does not starts with switch identifier
                if (('-D' == $arg) && (!StringHelper::startsWith('-', $args[$i + 1]))) {
                    $name = $args[++$i];
                } else {
                    $name = substr($arg, 2);
                }

                $value = null;
                $posEq = strpos($name, "=");
                if ($posEq !== false) {
                    $value = substr($name, $posEq + 1);
                    $name = substr($name, 0, $posEq);
                } elseif ($i < count($args) - 1 && !StringHelper::startsWith("-D", $args[$i + 1])) {
                    $value = $args[++$i];
                }
                self::$definedProps->setProperty($name, $value);
            } elseif ($arg == "-logger") {
                if (!isset($args[$i + 1])) {
                    $msg = "You must specify a classname when using the -logger argument";
                    throw new ConfigurationException($msg);
                }

                $this->loggerClassname = $args[++$i];
            } elseif ($arg == "-no-strict") {
                $this->strictMode = false;
            } elseif ($arg == "-strict") {
                $this->strictMode = true;
            } elseif ($arg == "-inputhandler") {
                if ($this->inputHandlerClassname !== null) {
                    throw new ConfigurationException("Only one input handler class may be specified.");
                }
                if (!isset($args[$i + 1])) {
                    $msg = "You must specify a classname when using the -inputhandler argument";
                    throw new ConfigurationException($msg);
                }

                $this->inputHandlerClassname = $args[++$i];
            } elseif ($arg === "-propertyfile") {
                $i = $this->handleArgPropertyFile($args, $i);
            } elseif ($arg === "-keep-going" || $arg === "-k") {
                $this->keepGoingMode = true;
            } elseif ($arg == "-longtargets") {
                self::$definedProps->setProperty('phing.showlongtargets', 1);
            } elseif ($arg == "-projecthelp" || $arg == "-targets" || $arg == "-list" || $arg == "-l" || $arg == "-p") {
                // set the flag to display the targets and quit
                $this->projectHelp = true;
            } elseif ($arg == "-find") {
                // eat up next arg if present, default to build.xml
                if ($i < count($args) - 1) {
                    $this->searchForThis = $args[++$i];
                } else {
                    $this->searchForThis = self::DEFAULT_BUILD_FILENAME;
                }
            } elseif (substr($arg, 0, 1) == "-") {
                // we don't have any more args
                self::printUsage();
                self::$err->write(PHP_EOL);
                throw new ConfigurationException("Unknown argument: " . $arg);
            } else {
                // if it's no other arg, it may be the target
                $this->targets[] = $arg;
            }
        }

        // if buildFile was not specified on the command line,
        if ($this->buildFile === null) {
            // but -find then search for it
            if ($this->searchForThis !== null) {
                $this->buildFile = $this->_findBuildFile(self::getProperty("user.dir"), $this->searchForThis);
            } else {
                $this->buildFile = new PhingFile(self::DEFAULT_BUILD_FILENAME);
            }
        }

        try {
            // make sure buildfile (or buildfile.dist) exists
            if (!$this->buildFile->exists()) {
                $distFile = new PhingFile($this->buildFile->getAbsolutePath() . ".dist");
                if (!$distFile->exists()) {
                    throw new ConfigurationException(
                        "Buildfile: " . $this->buildFile->__toString() . " does not exist!"
                    );
                }
                $this->buildFile = $distFile;
            }

            // make sure it's not a directory
            if ($this->buildFile->isDirectory()) {
                throw new ConfigurationException("Buildfile: " . $this->buildFile->__toString() . " is a dir!");
            }
        } catch (IOException $e) {
            // something else happened, buildfile probably not readable
            throw new ConfigurationException("Buildfile: " . $this->buildFile->__toString() . " is not readable!");
        }

        $this->loadPropertyFiles();

        $this->readyToRun = true;
    }
834281
public static String run(String [] args) {
		if (args.length < 4) {
			return "Syntax error : args : " + " phpExec|default workingDirectory initPhpFile";
		}
		String [] l = new String[args.length - 1];
		for(int i = 3; i < args.length; i ++) {
			l[i - 1] = args[i];
		}
		l[0] = "--sud";
		l[1] = PHPSud.class.getCanonicalName() + ";" + args[0] + ";" + args[1] + ";" + args[2];
		StringBuilder cmd = new StringBuilder();
		for(String s : l) {
			cmd.append(s).append(" ");
		}
		System.out.println("Command line : " + cmd.toString());
		try {
			CommandLineRunner runner = new CommandLineRunner();
			RecorderMonitor recorderMonitor = new RecorderMonitor();
			LoggingMonitor loggingMonitor = new LoggingMonitor( System.out, System.err );
			runner.setMonitor(new CompositeSpecificationRunnerMonitor(recorderMonitor, loggingMonitor));
			runner.run(l);

			if (recorderMonitor.getStatistics().hasFailed()) {
				return "Some errors detected";
			}
			return "";
		} catch (Exception e) {
			return "Exception when executing tests " + e.toString();
		}
	}
937473
private static function exec(array $args)
    {
        $cmd = implode(' ', array_map('escapeshellarg', $args)) . ' 2>/dev/null';
        $process = proc_open($cmd, [1 => ['pipe', 'w']], $pipes);
        $output = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        if (proc_close($process) !== 0) {
            return false;
        }

        return $output;
    }
1168667
public function getJob($command, array $args = [])
    {
        if (null !== $job = $this->findJob($command, $args)) {
            return $job;
        }

        throw new \RuntimeException(sprintf('Found no job for command "%s" with args "%s".', $command, json_encode($args)));
    }
69750
public function handle(Args $args)
    {
        $target = $args->getArgument('target');

        if (!in_array($target, self::$targets)) {
            throw new RuntimeException(sprintf(
                'Invalid build target "%s". Expected one of: "%s"',
                $target,
                implode('", "', self::$targets)
            ));
        }

        if ('all' === $target || 'factory' === $target) {
            $this->factoryManager->autoGenerateFactoryClass();
        }

        if ('all' === $target || 'repository' === $target) {
            $this->repoManager->clearRepository();
            $this->repoManager->buildRepository();
        }

        if ('all' === $target || 'discovery' === $target) {
            $this->discoveryManager->clearDiscovery();
            $this->discoveryManager->buildDiscovery();
            $this->discoveryManager->removeObsoleteDisabledBindingDescriptors();
        }

        return 0;
    }
368011
public function generateKey(array $options = [])
	{
		// Generate the encryption key.
		try
		{
			$public = DefuseKey::createNewRandomKey();
		}
		catch (EnvironmentIsBrokenException $ex)
		{
			throw new \RuntimeException('Cannot safely create a key', $ex->getCode(), $ex);
		}

		// Create the new encryption key object.
		return new Key('crypto', $public->saveToAsciiSafeString(), $public->getRawBytes());
	}
1213460
public function run($args)
    {
        $args = $this->parseArgs($args);
        foreach ($this->options as $argument => $attribute) {
            $this->{$attribute} = in_array($argument, $args);
            if ($this->{$attribute}) {
                $args = array_values(array_diff($args, [$argument]));
            }
        }

        if (!isset($args[0]) || !$args[0]) {
            return $this->initPath($this->cwd);
        }

        $projectName = $args[0];
        if (!$this->existsProjectName($projectName)) {
            return "> Producer: Project '{$this->projectsDir}/{$projectName}' not found.\n";
        }

        return $this->initPath($this->getProjectDir($projectName));
    }
1013009
public function execute($method, array $options = [], array $arguments = []) {
        $params = [];

        if (count($options) > 0) {
            $params['options'] = $options;
        }

        if (count($arguments) > 0) {
            $params['arguments'] = $arguments;
        }

        $result = $this->api->request(
            $method,
            $params
        );

        if (!array_key_exists('success', $result)) {
            throw new RuntimeException('Missing success status');
        }

        if (!is_bool($result['success']) || $result['success'] === false) {
            throw new RuntimeException('Command failed');
        }

        if (!array_key_exists('output', $result)) {
            throw new RuntimeException('Missing output');
        }

        if (!is_array($result['output'])) {
            throw new RuntimeException('Invalid output');
        }

        return $result['output'];
    }
148463
public function execute(array $args, array $options = [])
    {
        if (!isset($args[0])) {
            throw new \InvalidArgumentException('arg action must be input');
        }
        $action = explode('::', $args[0]);
        if (!class_exists($action[0])) {
            throw new \InvalidArgumentException('action not not found!');
        }

        ProcessManage::rmTask($action);
    }