Skip to content

Commit

Permalink
fix empty value
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Fuzeto committed Mar 7, 2018
1 parent ba476a3 commit 1bad81f
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 @@ -473,9 +473,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 1bad81f

Please sign in to comment.