From: Michael Wallner Date: Wed, 4 Mar 2015 19:18:27 +0000 (+0100) Subject: support concatenated short opts like -vps X-Git-Tag: v1.0.3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2394c71d8ebfa6ca114587ee88859c588a0fc85f;p=pharext%2Fpharext support concatenated short opts like -vps --- diff --git a/bin/pharext b/bin/pharext index 4076d33..1239579 100755 Binary files a/bin/pharext and b/bin/pharext differ diff --git a/src/pharext/CliArgs.php b/src/pharext/CliArgs.php index f93ad7b..fb9a7ec 100644 --- a/src/pharext/CliArgs.php +++ b/src/pharext/CliArgs.php @@ -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)) {