Skip to content

Commit

Permalink
Merge pull request #64 from peter279k/add_split_extra_arg
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s authored Apr 14, 2023
2 parents 9a433c6 + 3d8bd1d commit aab2728
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/OptionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ protected function preprocessingArguments(array $argv)
foreach ($argv as $arg) {
if ($arg === '--') {
$afterDash = true;
continue;
}
if ($afterDash) {
$newArgv[] = $arg;
Expand Down Expand Up @@ -175,6 +174,11 @@ public function parse(array $argv)
}

$spec = $this->specs->get($arg->getOptionName());

if ($arg->arg === '--') {
continue;
}

if (!$spec) {
throw new InvalidOptionException('Invalid option: '.$arg);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ContinuousOptionParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function argumentProvider()
['program','-v', '-c', 'subcommand1', '--as', 99, 'arg1', 'arg2', 'arg3', '--','zz','xx','vv'],
[
'app' => ['verbose' => true],
'args' => ['arg1', 'arg2', 'arg3', 'zz', 'xx', 'vv']
'args' => ['arg1', 'arg2', 'arg3', '--', 'zz', 'xx', 'vv']
],
],
];
Expand Down

0 comments on commit aab2728

Please sign in to comment.