3 ms·
The problem I have with optimist it that it provides no default usage statement (last time I checked). One of the big selling points of argument processors is t
by shtylman 15y ago
The problem I have with optimist it that it provides no default usage statement (last time I checked). One of the big selling points of argument processors is that you can define the args and some descriptions so it will generate the usage statement. This cuts down of re-typing and errors. It also has the benefit of autocomplete tools being able to handle standard formats.
- IsaacSchlueter 15y agoThere are a few option parsers in node that do automatically generate usage. However, this is actually quite problematic if you have a lot of options. Check out https://github.com/harthur/nomnom https://github.com/harthur/nomnom, it may be more to your liking.
- peterbraden 15y agoI really like nomnom. It's a super tight way to define options and commands.
- vailripper 15y agoAgreed - personally I use https://github.com/visionmedia/commander.js https://github.com/visionmedia/commander.js for this reason.
- rektide 15y ago[1] demonstrates the use of default. 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