Exemple #1
0
  yasca.bat c:\\source_code
  yasca.sh /opt/dev/source_code
  php.exe Main.php --pluginsIgnore,FindBugs,PMD,Antic,JLint /opt/dev/source_code
  php.exe Main.php --log,ConsoleLog,7 "c:/orange/"
  php.exe Main.php --onlyPlugins,BuiltIn c:/example/


EOT;
    if ($_SERVER['argc'] < 2) {
        print $help;
        exit(0);
    }
    foreach ((new \Yasca\Core\IteratorBuilder())->from($_SERVER['argv'])->skip(1)->selectKeys(static function ($arg) {
        $options = \str_getcsv($arg);
        $switch = \array_shift($options);
        return [Operators::nullCoalesce($options, []), $switch];
    }) as $switch => $options) {
        //As of PHP 5.4, switch() uses loose comparision instead of strict.
        //Use if/elseif instead.
        if ($switch === '-h' || $switch === '--help' || $switch === '/?') {
            print $help;
            exit(0);
        } elseif ($switch === '-v' || $switch === '--version') {
            print $version;
            exit(0);
        } elseif ($switch === '--pluginInstalled' || $switch === '--pluginsInstalled' || $switch === '--installedPlugins' || $switch === '--installedPlugin') {
            (new \Yasca\Core\IteratorBuilder())->from(\Yasca\Plugin::$installedPlugins)->selectMany(static function ($plugins) {
                return $plugins;
            })->forAll(static function ($plugin) {
                print "{$plugin}\n";
            });
Exemple #2
0
if ($_SERVER['argc'] < 2){
    print($help);
    exit(0);
}

foreach (
    (new \Yasca\Core\IteratorBuilder)
    ->from($_SERVER['argv'])
    //Skip the name of the script file
    ->skip(1)
    ->selectKeys(static function($arg){
        $options = \str_getcsv($arg);
        $switch = \array_shift($options);
        return [
            Operators::nullCoalesce($options,[]),
            $switch,
        ];
    })

    as $switch => $options
){
    //As of PHP 5.4, switch() uses loose comparision instead of strict.
    //Use if/elseif instead.
    if          ($switch === '-h'         ||
              $switch === '--help'  ||
              $switch === '/?'
      ){
        print($help);
        exit(0);