Skip to content
Myr

Rework version option description

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

authored by John Gee · committed by John Gee · parent 4309421 · Browse files · 1 file+11 added−7 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+11 added−7 removed

  • other:+11 added−7 removed

1 file+11 added−7 removed

modified:Readme.md+11 added-7 removed
147 unmodified lines
148```149150### Custom option processing151152You may specify a function to do custom processing on options. The callback function receives two parameters, the user specified value and the 152You may specify a function to do custom processing of option values. The callback function receives two parameters, the user specified value and the 153previous value for the option. It returns the new value for the option.154155This allows you to coerce the option value to the desired type, or accumulate values, or do entirely custom processing.156
50 unmodified lines
207```208209### Version option210211Calling the `version` implicitly adds the `-V` and `--version` options to the command.212When either of these options is present, the command prints the version number and exits.211The optional `version` method adds handling for displaying the command version. The default option flags are `-V` and `--version`, and when present the command prints the version number and exits.212213```js214 program.version('0.0.1');215```216217```bash218 $ ./examples/pizza -V219 0.0.1220```221217If you want your program to respond to the `-v` option instead of the `-V` option, simply pass custom flags to the `version` method using the same syntax as the `option` method.222You may specify custom flags by passing an additional parameter to the `version` method using the same syntax as the `option` method. The version flags can be named anything, but a long name is required.223224```js220program221 .version('0.0.1', '-v, --version')225program.version('0.0.1', '-v, --version');226```227224The version flags can be named anything, but the long option is required.228229230## Command-specific options231232You can attach options to a command.233
286 unmodified lines