From: Michael Wallner Date: Fri, 6 Mar 2015 10:45:17 +0000 (+0100) Subject: support --long-opt=arg X-Git-Tag: v1.1.0~8 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=53ef0a7d5e3ee8bb3f3d12edd03a52a5697c7e3e;p=pharext%2Fpharext support --long-opt=arg --- diff --git a/bin/pharext b/bin/pharext index 641f4f5..07bdaa5 100755 Binary files a/bin/pharext and b/bin/pharext differ diff --git a/src/pharext/CliArgs.php b/src/pharext/CliArgs.php index d753931..99992bd 100644 --- a/src/pharext/CliArgs.php +++ b/src/pharext/CliArgs.php @@ -127,6 +127,13 @@ class CliArgs implements \ArrayAccess return "-$s"; }, str_split(substr($o, 1)))); $o = $argv[$i]; + } elseif ($o{0} === '-' && strlen($o) > 2 && $o{1} === '-' && 0 < ($eq = strpos($o, "="))) { + $argc++; + array_splice($argv, $i, 1, [ + substr($o, 0, $eq++), + substr($o, $eq) + ]); + $o = $argv[$i]; } if (!isset($this->spec[$o])) { diff --git a/tests/src/pharext/CliArgsTest.php b/tests/src/pharext/CliArgsTest.php index ff05c8f..4e77b20 100644 --- a/tests/src/pharext/CliArgsTest.php +++ b/tests/src/pharext/CliArgsTest.php @@ -112,6 +112,14 @@ class CliArgsTest extends \PHPUnit_Framework_TestCase } $this->assertTrue(isset($error)); } + + public function testLongEquals() { + $this->assertNull($this->args->configure); + foreach ($this->args->parse(1, ["--configure=--with-lib=/opt/lib"]) as $error) { + throw new \Exception("Unexpected parse error: $error"); + } + $this->assertSame(["--with-lib=/opt/lib"], $this->args->configure); + } public function testValidate() { $this->args->compile([