Example #1
0
 public static function processArg()
 {
     $sws = array('-v' => false, '-h' => false, '-ini' => false, '-D' => 2);
     $params = array('ini' => false);
     list($switches, $parameters) = \Jelix\BuildTools\Cli\Params::getOptionsAndParams($_SERVER['argv'], $sws, $params);
     if (isset($parameters['ini'])) {
         Environment::addIni($parameters['ini']);
     }
     if (isset($switches['-D'])) {
         foreach ($switches['-D'] as $var) {
             if (preg_match("/^(\\w+)=(.*)\$/", $var, $m)) {
                 Environment::set($m[1], $m[2]);
             } else {
                 throw new Exception('bad syntax for -D option  :' . $var . "\n");
             }
         }
     }
     if (isset($switches['-v'])) {
         Environment::set('VERBOSE_MODE', true);
     }
     if (isset($switches['-h'])) {
         echo Environment::help();
         exit(0);
     }
     if (isset($switches['-ini'])) {
         echo Environment::getIniContent();
         exit(0);
     }
 }
Example #2
0
<?php

/**
* @author      Laurent Jouanneau
* @contributor
* @copyright   2006-2015 Laurent Jouanneau
* @link        http://www.jelix.org
* @licence     GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html
*/
require_once __DIR__ . '/../lib/autoloader.php';
// arguments:  directory
// directory: directory path where the files will be converted
try {
    $sws = array('-n' => false);
    $params = array('dirpath' => true);
    list($switches, $parameters) = \Jelix\BuildTools\Cli\Params::getOptionsAndParams($_SERVER['argv'], $sws, $params);
} catch (Exception $e) {
    echo "dos2unix error : ", $e->getMessage(), "\n";
    echo "php dos2unix.php [-n] dir\n   -n: no modification, test mode\n";
    exit(1);
}
$dirpath = $parameters['dirpath'];
if (substr($dirpath, -1) == '/') {
    $dirpath = substr($dirpath, 0, -1);
}
function parsePath($dir)
{
    global $switches;
    if ($dh = opendir($dir)) {
        $dirlist = array();
        $cdok = false;