diff --git a/setup/cli/modules/class.module.php b/setup/cli/modules/class.module.php index 02c9b5f5c11b0327c8027084f69f30bb91212d00..c2321aa341f3419ebf3878af60af34c8eb5cc1ab 100644 --- a/setup/cli/modules/class.module.php +++ b/setup/cli/modules/class.module.php @@ -4,10 +4,6 @@ class Option { var $default = false; - function Option() { - call_user_func_array(array($this, "__construct"), func_get_args()); - } - function __construct($options=false) { list($this->short, $this->long) = array_slice($options, 0, 2); $this->help = (isset($options['help'])) ? $options['help'] : ""; @@ -119,10 +115,6 @@ class Module { var $_options; var $_args; - function Module() { - call_user_func_array(array($this, '__construct'), func_get_args()); - } - function __construct() { $this->options['help'] = array("-h","--help", 'action'=>'store_true', @@ -262,21 +254,36 @@ class Module { function parseArgs($argv) { $options = $args = array(); $argv = array_slice($argv, 0); + $more_opts = true; while ($arg = array_shift($argv)) { if (strpos($arg, '=') !== false) { list($arg, $value) = explode('=', $arg, 2); array_unshift($argv, $value); } + if ($arg == '--') { + $more_opts = false; + continue; + } + // Allow multiple simple args like -Dvt + if ($arg[0] == '-' && strlen($arg) > 2) { + foreach (str_split(substr($arg, 2)) as $O) + array_unshift($argv, "-{$O}"); + $arg = substr($arg, 0, 2); + } $found = false; - foreach ($this->options as $opt) { - if ($opt->short == $arg || $opt->long == $arg) { - if ($opt->handleValue($options, $argv)) - array_shift($argv); - $found = true; + if ($more_opts && $arg[0] == '-') { + foreach ($this->options as $opt) { + if ($opt->short == $arg || $opt->long == $arg) { + if ($nargs = $opt->handleValue($options, $argv)) + while ($nargs--) + array_shift($argv); + $found = true; + } } } - if (!$found && $arg[0] != '-') + if (!$found && (!$more_opts || $arg[0] != '-')) $args[] = $arg; + // XXX else show help if $strict? } return array($options, $args); }