'process' module
Arguments accessible via 'process.argv'
Array of arguments
3
COMMAND-
LINE IN NODE
Slide 4
Slide 4 text
4
Slide 5
Slide 5 text
Perfectly fine if you only need one argument
E.g. accessing the first argument: process.argv[2]
Parsing of options becomes unmanageable
5
PROBLEMS WITH
THIS APPROACH
Slide 6
Slide 6 text
Module to help ease the pain of parsing
command-line options
Simple, natural API
Auto generated --help and --version
6
COMMANDER.JS
https://github.com/visionmedia/commander.js/
Slide 7
Slide 7 text
7
Slide 8
Slide 8 text
8
Slide 9
Slide 9 text
Options don't need to be defined
All options are parsed automatically
Also has default values, aliases
Many more features
9
NODE-OPTIMIST
https://github.com/substack/node-optimist
Slide 10
Slide 10 text
10
Slide 11
Slide 11 text
11
Slide 12
Slide 12 text
aparser
cli
node-arguments
And many more …
12
SOME MORE
LIBRARIES
Slide 13
Slide 13 text
13
WHERE HAVE I USED IT?
https://github.com/domharrington/gitme