-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add helpGroup for options and commands #1910
Conversation
Looks interesting, and would perfectly fix my current issue :) |
I am still wondering about:
I want to think a bit more about consistency across the API and whether an options-bag is the best approach. (And have been busy reviewing other PRs.) |
It's not the prettiest but I can't think of any better alternative, and it makes sense in regard to the existing api. |
(Thanks for comments @sinedied ) |
If I can't decide for now on a built-in way of customising the version option and help option and help command, could maybe leave it to the author! Thinking of this as an interim work-around rather than permanent solution. class MyCommand extends Command {
createCommand(name) {
const cmd = new MyCommand(name);
// Set group on the special built-in command.
if (cmd.name() === 'help')
cmd.helpGroup('Demo Commands:');
return cmd;
}
createOption(flags, description) {
const option = super.createOption(flags, description);
// Set group on the special built-in options.
if (option.long === '--version' || option.long === '--help')
option.helpGroup('Demo Options:');
return option;
}
} |
This would be totally fine for me given that's probably an infrequent use case. |
Correct. Still need that work from this PR. |
There hasn't been much interest in this feature to date. There is a reasonable chunk of work to do a full solution. Putting this draft away for now. This issue prompted a couple of refactors so may be easier to customise built-in help option and help command in future: #2006 #2087 I liked "section" approach used in #1897 example implementation which could possibly also help with #1870. (Not included in this draft.) |
Problem
Some people with larger programs would like to break up their commands and options into groups in the help. There have not been a lot of requests for this, but it is something I had noticed as a possible enhancement.
See: #78 #374 (comment) #1897
Help groups are common in "big" programs, but big programs often have custom help systems anyway! (e.g. git, npm)
Solution
Add
.helpGroup()
to Command and Option. Use the help groups as titles in the help.To support built-in features and external commands, add
{helpGroup}
configuration to:.version()
.helpOption()
.addHelpCommand()
ChangeLog