Skip to content
Myr

Add mention of makeOptionMandatory in README (#1797)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by John Gee · committed by GitHub · parent 72be61c · Browse files · 1 file+3 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−1 removed

  • other:+3 added−1 removed

1 file+3 added−1 removed

modified:Readme.md+3 added-1 removed
328 unmodified lines
329For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md).330331### Required option332333You may specify a required (mandatory) option using `.requiredOption`. The option must have a value after parsing, usually specified on the command line, or perhaps from a default value (say from environment). The method is otherwise the same as `.option` in format, taking flags and description, and optional default value or custom processing.333You may specify a required (mandatory) option using `.requiredOption()`. The option must have a value after parsing, usually specified on the command line, or perhaps from a default value (say from environment). The method is otherwise the same as `.option()` in format, taking flags and description, and optional default value or custom processing.334335Example file: [options-required.js](./examples/options-required.js)336337```js
102 unmodified lines
440$ extra --disable-server --port 8000441error: option '--disable-server' cannot be used with option '-p, --port <number>'442```443444Specify a required (mandatory) option using the `Option` method `.makeOptionMandatory()`. This matches the `Command` method [.requiredOption()](#required-option).445446### Custom option processing447448You may specify a function to do custom processing of option-arguments. The callback function receives two parameters,449the user specified option-argument and the previous value for the option. It returns the new value for the option.
667 unmodified lines