Skip to content

Commit 24ca282

Browse files
authored
Throw error for Option to option() or requiredOption() (#1655)
* Throw error for wrong argument to option or requiredOption * Make test and error message more specific
1 parent 9a56cc7 commit 24ca282

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/command.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
580580
* @api private
581581
*/
582582
_optionEx(config, flags, description, fn, defaultValue) {
583+
if (typeof flags === 'object' && flags instanceof Option) {
584+
throw new Error('To add an Option object use addOption() instead of option() or requiredOption()');
585+
}
583586
const option = this.createOption(flags, description);
584587
option.makeOptionMandatory(!!config.mandatory);
585588
if (typeof fn === 'function') {

0 commit comments

Comments
 (0)