-
-
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
Expand help customisation with .addHelpText #1296
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
To be safe, the change to use The other changes are backwards compatible, as the |
This comment has been minimized.
This comment has been minimized.
I am happier with how this is looking now with an explicit routine which is more readable than an event listener, and leaving the ability to override the built-in help out of this routine. |
I deprecated the callbacks to |
Could you merge |
Oops, will do. I was merging 6.1 into the PR so the diff against develop looked better, missed doing 7.x too. |
I have merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Only a (minor) issue in the new version:
A little confusing. If case 1 should behave as Besides this minor issue, the new version is excellent. Thanks! |
Case 2 is a special case. If there is an empty string then nothing is output. This is to support a function generating the string deciding that there is nothing to be displayed. |
OK, understand. Maybe adding a line to documentation stating this could be useful. Something like this at the end of the Custom help paragraph: “If the string or the output of the function is an empty string, nothing is output, otherwise the string is output followed by a newline”. |
Pull Request
Problem
stdout
even when being displayed as an "error"See #1225 for collected custom help issues, and #997 for error output.
Solution
Add
.addHelpText()
which takes a position as first parameter, and a string to add or a function returning a string. Position is 'before' or 'after' to affect just this command, and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.For example:
Also:
.help()
and.outputHelp()
can be passed{ error: true }
to write to stderr..help()
and.outputHelp()
.on('--help')
ChangeLog
.addHelpText()
to add text before or after the built-in help, for just current command or also for all subcommands (Expand help customisation with .addHelpText #1296).help()
and.outputHelp()
(removed from README).on('--help')
(removed from README)