diff --git a/src/Commando/Command.php b/src/Commando/Command.php index 4d18b47..6459fbb 100755 --- a/src/Commando/Command.php +++ b/src/Commando/Command.php @@ -439,9 +439,14 @@ public function parse() // the next token MUST be an "argument" and not another flag/option $token = array_shift($tokens); list($val, $type) = $this->_parseOption($token); - if ($type !== self::OPTION_TYPE_ARGUMENT) - throw new \Exception(sprintf('Unable to parse option %s: Expected an argument', $token)); - $keyvals[$name] = $val; + + if ($type !== self::OPTION_TYPE_ARGUMENT && $option->getDefault() === null) { + throw new \Exception(sprintf('Unable to parse option %s: Expected an argument or default', $token)); + } + + $keyvals[$name] = ($type !== self::OPTION_TYPE_ARGUMENT) + ? $option->getDefault() + : $val; } } }