cordova-cli icon indicating copy to clipboard operation
cordova-cli copied to clipboard

Rewrite CLI using better options parser (possibly yargs)

Open raphinesse opened this issue 7 years ago • 4 comments

Requirements

  • sub-command support
  • generate usage text from specification

AFAICT, nopt does not satisfy any of those, so let's look at some alternatives.

Disqualifications

  • meow and optionator have no sub-command support: https://github.com/sindresorhus/meow/issues/69, https://github.com/gkz/optionator/issues/6
  • optimist and minimist are not maintained anymore: https://github.com/substack/node-optimist/issues/132, https://github.com/substack/minimist/issues/115

That leaves us with yargs vs commander. Multiple reasons let me favor yargs:

  • Seemingly better docs
  • Faster growing download count (= popularity?)
  • Younger project
  • The pirate theme :wink:

Related: #309

raphinesse avatar Aug 30 '18 14:08 raphinesse

I'm not too familiar with the CLI args parsers, what does sub-command support mean in this context? I guess knowing that will probably explain the need to switch away from nopt :)

Menardi avatar Sep 01 '18 08:09 Menardi

@Menardi I'm thinking of something like this: https://github.com/yargs/yargs/blob/master/docs/advanced.md#example-command-hierarchy-using-commanddir

I will try to provide a Motivation section to this issue when I find the time.

raphinesse avatar Sep 02 '18 09:09 raphinesse

If you wonder what Cordova might look like using Commander for the CLI, I tried emulating the Cordova CLI to try out some new features coming in Commander v5: https://github.com/shadowspawn/commander-does-cordova.git

(This isn't a recommendation to use Commander, just commenting for your possible interest.)

shadowspawn avatar Feb 29 '20 23:02 shadowspawn

Hi! Browsing through other cli-libraries I bumped into this issue. I have been building a cli-parser myself (for educational purposes) and reading this issue's descriptions, seems it might be a good fit: https://github.com/carloscortonc/cli-er#readme

Would love any feedback/suggestions! 👐

carloscortonc avatar Aug 07 '23 20:08 carloscortonc