cacjs/cac

Show root help for wildcard command

egoist opened this issue · 3 comments

If you have a wildcard command like:

cli.option('foo', desc)

const wildcard = cli.command('*', desc, handler)
wildcard.option('bar', desc)

And when you run cli.js --help it currently prints message that includes bar instead of foo. Which means you can never see root help!

We should actually make wildcard command show root help instead of command help, and force user to add an alias name to the wildcard command so that it's possible to get the help for your wildcard command too:

cli.option('foo', desc)

const wildcard = cli.command('*', { alias: 'hi', desc }, handler)
wildcard.option('bar', desc)

In this case, run cli.js --help for root help, run cli.js hi --help for the help of your wildcard command.

It looks like this was a breaking change, can you please document and/or put an example in the examples folder how to use wildcard option?

@egoist thank you