Skip to content

POC supporting verbose descriptions for commands #1362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 27, 2025

Conversation

brandenrodgers
Copy link
Contributor

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's describe export.

Screenshots

hs --help before

image

hs --help after

image

hs auth --help before

image

hs auth --help after

image (ignore the "undefined" in there. I just didn't pass in the config file constant to i18n)

TODO

Who to Notify

@brandenrodgers
Copy link
Contributor Author

Updated screenshots for hs auth --help

Before

image

After

image

@brandenrodgers
Copy link
Contributor Author

Even if commands don't specify verbose descriptions, they can still benefit from the formatting updates:

Before

image

After

image

joe-yeager
joe-yeager previously approved these changes Mar 20, 2025
@brandenrodgers brandenrodgers merged commit c9b3518 into main Mar 27, 2025
1 check passed
@brandenrodgers brandenrodgers deleted the br/short-and-long-command-descriptions branch March 27, 2025 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants