POC supporting verbose descriptions for commands #1362
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description and Context
I was poking around Stripe's CLI and noticed they support multiple descriptions for commands. A short one that shows when the command is listed a a child of another command, and a longer one when you run the help command for a specific command. Our equivalent would be
hs --help
vs.hs auth --help
. For the former, it's nice to provide a concise description because the list of commands is long and it's hard to parse if each command has a wordy description. For the latter, it would be ideal to give the user more detailed information.Unfortunately, yargs doesn't make this easy out of the box, but I think I found a pretty clean solution that would let us provide both a short and long description for commands. This POC shows what it could look like for the
hs auth
command.The
addVerboseDescribe
is pretty straightforward. It checks to see if the user included the--help
flag, grabs the original help output, and then logs out a new one. I tried to make it safer by allowing it to safely throw. If it throws, the help output will just fall back to the default yargs behavior, which is to log out the command'sdescribe
export.Screenshots
hs --help
beforehs --help
afterhs auth --help
beforehs auth --help
afterTODO
Who to Notify