function __construct($request) { if ($request == null) { return; } $this->request = $request; $params = $this->request->params; unset($params['module']); unset($params['action']); $action = new jSelectorAct($this->request->params['action']); if (!in_array($action->method, get_class_methods(get_class($this)))) { throw new jException('jelix~errors.cli.unknown.command', $action->method); } $opt = isset($this->allowed_options[$action->method]) ? $this->allowed_options[$action->method] : array(); $par = isset($this->allowed_parameters[$action->method]) ? $this->allowed_parameters[$action->method] : array(); list($this->_options, $this->_parameters) = jCmdUtils::getOptionsAndParams($params, $opt, $par); }
/** * * @param jRequest $request */ function __construct($request) { // we receive null when the controller is created only for help if ($request == null) { return; } $this->request = $request; $params = $this->request->params; unset($params['module']); unset($params['action']); $method = jApp::coord()->action->method; if (!in_array($method, get_class_methods(get_class($this)))) { throw new jException('jelix~errors.cli.unknown.command', $method); } $opt = isset($this->allowed_options[$method]) ? $this->allowed_options[$method] : array(); $par = isset($this->allowed_parameters[$method]) ? $this->allowed_parameters[$method] : array(); list($this->_options, $this->_parameters) = jCmdUtils::getOptionsAndParams($params, $opt, $par); }
/** * @package jBuildTools * @author Laurent Jouanneau * @contributor * @copyright 2006-2007 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 dirname(__FILE__) . '/lib/jCmdUtils.class.php'; // arguments : repertoire // repertoire : le chemin du repertoire où les fichiers seront convertis try { $sws = array('-n' => false); $params = array('dirpath' => true); list($switches, $parameters) = jCmdUtils::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;
function init() { $sws = array('-v' => false, '-h' => false, '-ini' => false, '-D' => 2); $params = array('ini' => false); list($switches, $parameters) = jCmdUtils::getOptionsAndParams($_SERVER['argv'], $sws, $params); if (isset($parameters['ini'])) { ENV::addIni($parameters['ini']); } if (isset($switches['-D'])) { foreach ($switches['-D'] as $var) { if (preg_match("/^(\\w+)=(.*)\$/", $var, $m)) { ENV::set($m[1], $m[2]); } else { throw new Exception('bad syntax for -D option :' . $var . "\n"); } } } if (isset($switches['-v'])) { ENV::set('VERBOSE_MODE', true); } if (isset($switches['-h'])) { echo ENV::help(); exit(0); } if (!isset($parameters['ini'])) { throw new Exception("ini file name forgotten\n"); } if (isset($switches['-ini'])) { echo ENV::getIniContent(); exit(0); } }