From 53ef0a7d5e3ee8bb3f3d12edd03a52a5697c7e3e Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 6 Mar 2015 11:45:17 +0100 Subject: [PATCH] support --long-opt=arg --- bin/pharext | Bin 34135 -> 34353 bytes src/pharext/CliArgs.php | 7 +++++++ tests/src/pharext/CliArgsTest.php | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/bin/pharext b/bin/pharext index 641f4f50627e67bb5c63ae6ddc712d610d833bbb..07bdaa54e897ef422c3cefe2a12a344b24ceb743 100755 GIT binary patch delta 542 zcmccK#k8@9X+yTu)K?a84- zTs`@S6vSX_pgFU5FB1i6^VJW|FD*(=b;&H!E66DL$;iL}atw&xcJ}^{Z9p0Xgn_sq zBe5v8qD0?0C)2Sgy%?liSrVcgL|dNo_M1FWS_R?=5e9~ytP|Ojb)+@G0)ngz3W!wD4Yo6d{gTkp?lMM>lC;P~9Y<99SX4*Wn?h_+OWV4U#Y7SO~ z)STkf$=_6TO>J#$71VXr71Y!e3>0h>G*nUx6>JrXONt8ei#1g8brh6rl{7Uq6{@*7 zfj}j(C_PzQdvd<2qIon}gtNFb38)&Z)Idi8s9jrIQwKu|D6R<>jNN=kbrb*OFJ20p zH^sDyY<}hXm1XkE<};f&H83$xZfV&r^P>LsPnOxI-`Dir2{*L8ac2Mapl84!U~qTx Gbpill&$^-j delta 360 zcmdnk!*soiX+yTuWM&z00Z$1AhS=PnAs{-@y53_lv$PryNMI=&1H*H9mio!FrIiIh z0@h3n46}DH6Wzwhz%V&oN)xQAl%0X$nfb@vlcQubzygA-3=9VX1Y{?hN~?ke<_R(| z1ScmO>ytmpsDN}! z$eL`v<+qw+b9}^f{>{hLm$Gf1@8!g_*+({yee!%S_RX_vzOqd2@)F&gqc=}*a*m$D zX0eP`k V9@u#AM1+JxkOR;?4DL?8P5=>lg<}8! 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([ -- 2.30.2