Skip to content

Commit 03f7d38

Browse files
codyj110roman-vanesyan
authored andcommittedNov 22, 2018
Added example of receiving args from options
Updated file to give example and how to manage arguments using options parsing.
1 parent 27aeac1 commit 03f7d38

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎Readme.md

+12
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ if (program.sauce) console.log(' with sauce');
6565
else console.log(' without sauce');
6666
```
6767

68+
To get string arguments from options you will need to use angle brackets <> for required inputs <br>
69+
or square brackets [] for optional inputs.
70+
71+
e.g. ```.option(' -m --myarg [myVar]', 'my super cool description')```<br>
72+
73+
Then to access the input if it was passed in.
74+
75+
e.g. ```var myInput = program.myarg```
76+
77+
**NOTE**: If you pass a argument without using brackets the example above will return true and not the value passed in.
78+
79+
6880
## Version option
6981

7082
Calling the `version` implicitly adds the `-V` and `--version` options to the command.

0 commit comments

Comments
 (0)
Please sign in to comment.