3 ms·
Anyone have a recommendation for Node.js? I've been extremely frustrated with commander [1]. [1] https://www.npmjs.com/package/commander https://www.npmjs.com/
by matt-attack 8y ago
Anyone have a recommendation for Node.js? I've been extremely frustrated with commander [1].
[1] https://www.npmjs.com/package/commander https://www.npmjs.com/package/commander
- Kamshak 8y agoTry oclif https://github.com/oclif/oclif https://github.com/oclif/oclif
- curry-castaway 8y agoI can second this recommendation – Oclif[0] is an absolute pleasure to use. I'd even encourage developers who aren't at a "full-stack Node.js shop" to give it a shot. I'm particularly impressed with the bash and zsh autocomplete support. I was delighted when I finished setting it up and everything worked perfectly on the first try. [0]: https://oclif.io/ https://oclif.io/
- jessaustin 8y agoHN had something on this a few months back, "12 Factor CLI Apps": https://news.ycombinator.com/item?id=18172689 https://news.ycombinator.com/item?id=18172689
- timdorr 8y agoLots of folks seem to like Yargs: https://github.com/yargs/yargs https://github.com/yargs/yargs
- tln 8y agoThere are lots of different approaches to defining the arguments and options. * You can build up a structure programmatically to define the arguments, as in commander, and then the usage and shape of the parsed result are implied. * You can provide the usage, as in docopt, and then the structure to define the args and shape of the parsed result are implied. * Or you can take the approach I did in fncli, which is to provide the shape of parsed result, as a function signature, and let the structure to define the args and usage be implied. https://www.npmjs.com/package/fncli https://www.npmjs.com/package/fncli This is possible because Javascript spec includes the function arguments as a string that can be parsed at run time. Because you're using ES6 syntax, you don't have to learn a new syntax (unlike docli or docopt). And although there are limitations, I've found this approach to handle modest CLI needs with an absolute minimum of fuss.
- tmpfs 8y agoYou may want to try my markdown based CLI definition tool: https://github.com/mkdoc/mkcli https://github.com/mkdoc/mkcli Generates help files, man pages, shell autocomplete for bash etc