Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Anyone have a recommendation for Node.js? I've been extremely frustrated with commander [1].

[1] https://www.npmjs.com/package/commander




I 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/


HN had something on this a few months back, "12 Factor CLI Apps":

https://news.ycombinator.com/item?id=18172689


There 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

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.


You may want to try my markdown based CLI definition tool:

https://github.com/mkdoc/mkcli

Generates help files, man pages, shell autocomplete for bash etc


Lots of folks seem to like Yargs: https://github.com/yargs/yargs




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: