Browse Source

Skip token when it is a subcommand

Not skipping the token will then cause it to be passed through parseArg()
which will see it as too many arguments being passed.
Rachman Chavik 11 years ago
parent
commit
ca598d1001
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/Console/ConsoleOptionParser.php

+ 3 - 1
src/Console/ConsoleOptionParser.php

@@ -474,7 +474,9 @@ class ConsoleOptionParser {
 		$params = $args = [];
 		$this->_tokens = $argv;
 		while (($token = array_shift($this->_tokens)) !== null) {
-			if (substr($token, 0, 2) === '--') {
+			if (isset($this->_subcommands[$token])) {
+				continue;
+			} elseif (substr($token, 0, 2) === '--') {
 				$params = $this->_parseLongOption($token, $params);
 			} elseif (substr($token, 0, 1) === '-') {
 				$params = $this->_parseShortOption($token, $params);