Node.js modules you should know about: optimist
catonmat.net
catonmat.net
Check out https://github.com/harthur/nomnom, it may be more to your liking.
var optimist= require('optimist')
.alias({e:'email', hp:'homepage', a:'auto', '?':'help'})
.default('auto',true)
I'm not sure whether I like the usage pattern of this code, which uses promises to resolve argv's[2]. I'll investigate having optimist autogenerate a usage statement; that would be convenient both as a dev and as a user. [1] https://github.com/rektide/git-ts/blob/master/publish.js#L3
[2] https://github.com/rektide/git-ts/blob/master/publish.js#L102./foo.js -x 1 -x 2 -x 3
(should give an array [1, 2, 3] for 'x')