support concatenated short opts like -vps v1.0.3
authorMichael Wallner <mike@php.net>
Wed, 4 Mar 2015 19:18:27 +0000 (20:18 +0100)
committerMichael Wallner <mike@php.net>
Wed, 4 Mar 2015 19:18:27 +0000 (20:18 +0100)
bin/pharext
src/pharext/CliArgs.php

index 4076d33167d62fae46ff122d9bef32a31e93b150..1239579392e15e386a889d58aabf1595e0304896 100755 (executable)
Binary files a/bin/pharext and b/bin/pharext differ
index f93ad7b884f5d9c2136e42b0e1c00df69c94428c..fb9a7ec5895ab02d31ef765b3cba31a81d1f2d7e 100644 (file)
@@ -103,6 +103,15 @@ class CliArgs implements \ArrayAccess
                for ($i = 0; $i < $argc; ++$i) {
                        $o = $argv[$i];
                        
+                       if ($o{0} === '-' && strlen($o) > 1 && $o{1} !== '-') {
+                               // multiple short opts, .e.g -vps
+                               $argc += strlen($o) - 2;
+                               array_splice($argv, $i, 1, array_map(function($s) {
+                                       return "-$s";
+                               }, str_split(substr($o, 1))));
+                               $o = $argv[$i];
+                       }
+
                        if (!isset($this->spec[$o])) {
                                yield sprintf("Unknown option %s", $argv[$i]);
                        } elseif (!$this->optAcceptsArg($o)) {