Skip to content

Commit

Permalink
nategood#83 - When the value assigned to the key is NULL. Instead of …
Browse files Browse the repository at this point in the history
…returning an exception, I consider the value set of the 'default' for the option.
  • Loading branch information
Leonardo Fuzeto committed Mar 7, 2018
1 parent 4b50548 commit 8516e18
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Commando/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 8516e18

Please sign in to comment.