Skip to content
Myr

Added example of receiving args from options

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

Updated file to give example and how to manage arguments using options parsing.

authored by codyj110 · committed by Roman Vanesyan · parent 27aeac1 · Browse files · 1 file+12 added−0 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+12 added−0 removed

  • other:+12 added−0 removed

1 file+12 added−0 removed

modified:Readme.md+12 added
63 unmodified lines
64if (program.sauce) console.log(' with sauce');65else console.log(' without sauce');66```6768To get string arguments from options you will need to use angle brackets <> for required inputs <br>69or square brackets [] for optional inputs. 7071e.g. ```.option(' -m --myarg [myVar]', 'my super cool description')```<br>7273Then to access the input if it was passed in.7475e.g. ```var myInput = program.myarg```7677**NOTE**: If you pass a argument without using brackets the example above will return true and not the value passed in.787980## Version option8182Calling the `version` implicitly adds the `-V` and `--version` options to the command.83When either of these options is present, the command prints the version number and exits.
346 unmodified lines