diff options
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -710,9 +710,10 @@ static function imageconvert($p) * Two or more blanks must be in front of option explanation * If an option 'verbose' is set, it will be set as debug variable as well so EDC('verbose', $bar) works * @param $helplines Usage parsed to determine options + * @param $p['optbeforearg'] Stop parsing options when first argument is encountered * @return Associative array of options */ -static function getopt($helplines) +static function getopt($helplines, $p = array()) { $GLOBALS['it_stdin'] = array( 'fd' => null, @@ -760,7 +761,7 @@ static function getopt($helplines) foreach (array_slice($_SERVER['argv'], 1) as $arg) { if ($noopts) - $result['args'][] = $arg; + $result['args'][] = $seenarg = $arg; else if ($eat) { if (it::match('^--?\w', $arg)) # Already next option => Missing argument? @@ -794,9 +795,12 @@ static function getopt($helplines) } } elseif($mandatoryargs) - $result[strtolower(array_shift($mandatoryargs))] = $arg; + $result[strtolower(array_shift($mandatoryargs))] = $seenarg = $arg; else - $result['args'][] = $arg; + $result['args'][] = $seenarg = $arg; + + if ($p['optbeforearg'] && $seenarg) + $noopts = true; } if ($err || $eat || $result['h'] || $result['help'] || $mandatoryargs) |