Skip to content

Commit

Permalink
Throw error for Option to option() or requiredOption() (#1655)
Browse files Browse the repository at this point in the history
* Throw error for wrong argument to option or requiredOption

* Make test and error message more specific
  • Loading branch information
shadowspawn committed Dec 21, 2021
1 parent 9a56cc7 commit 24ca282
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/command.js
Expand Up @@ -580,6 +580,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
* @api private
*/
_optionEx(config, flags, description, fn, defaultValue) {
if (typeof flags === 'object' && flags instanceof Option) {
throw new Error('To add an Option object use addOption() instead of option() or requiredOption()');
}
const option = this.createOption(flags, description);
option.makeOptionMandatory(!!config.mandatory);
if (typeof fn === 'function') {
Expand Down

0 comments on commit 24ca282

Please sign in to comment.