Commander.js: POLL: API for mandatory options

Created on 8 Sep 2019  路  5Comments  路  Source: tj/commander.js

The most upvoted and second oldest open issue is #230 to add support for mandatory options which must be specified on the command line.

(This is in addition to the existing support for options with a required value when the option is specified.)

There have been a number of possible forms for the API proposed. Which one would you like to see implemented? You can vote 馃憤 for more than one, and can vote 馃憥 against any you dislike.

Most helpful comment

.requiredOption

program.requiredOption('-f,--foo <value>', 'foo must be supplied');

All 5 comments

.requiredOption

program.requiredOption('-f,--foo <value>', 'foo must be supplied');

.optionEx

program.optionEx('-f,--foo <value>', 'foo must be supplied', { required: true });

.option with *

program.option('-f,--foo* ', 'foo must be supplied');

Thanks for the feedback. Implementing .requiredOption() in #1071.

Added .requiredOption() to v4.0.0 prerelease: #1067

Was this page helpful?
0 / 5 - 0 ratings

Related issues

youurayy picture youurayy  路  5Comments

RoXioTD picture RoXioTD  路  4Comments

winys picture winys  路  5Comments

DeoLeung picture DeoLeung  路  4Comments

oknoorap picture oknoorap  路  4Comments