-
-
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 a way to override help and version help message #963
Add a way to override help and version help message #963
Conversation
Did you see #870, which does the same thing? I'll give them a week to make contact, otherwise I'll work with you. Some of my feedback will be same as in #870 as it happens! I like the version changes, but not the help changes. In the longer term we might want something like edit: pull request was updated to match this approach If we go ahead, we'll want JSDoc and TypeScript updates for the Thank you for your contributions. |
@shadowspawn I changed my code to support I changed the hardcoded I added typings as well. Let me know if there are any other changes I should make. |
Oh, exciting! I was not expecting you to run with the full help customisation. I gave I'll let you know if I have any more requests or questions. |
@shadowspawn Did you have time to think about whether overriding the |
I'm still ok with The other names I came up with were |
(In top two of my PR queue. Hopefully take another look this week.) |
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.
Sorry, lots of feedback! But looking pretty good.
I added a bunch of smaller minor suggested changes on lines.
The bigger one is ideally want subcommand to get the custom flags too. (I have not looked into how to sensibly do that, possibly checking parent when created?)
i.e. currently get mixture of old and new help flags when have a sub-command
program
.help("-i, --ihelp", "foo foo") ;
program
.command("child")
.option("--gender", "specific gender of child")
.action((cmd) => {
console.log("Childsubcommand...");
});
Get the new flags for global help (as expected), but default flags for subcommand help:
$ node index.js -i
Usage: index [options] [command]
Options:
--global A global option
-i, --ihelp foo foo
Commands:
child [options]
Bagheera:963 john$ node index.js child
Childsubcommand...
Bagheera:963 john$ node index.js child -i
error: unknown option `-i'
Bagheera:963 john$ node index.js child -h
Usage: child [options]
Options:
--gender choose sex of child
-h, --help output usage information
I looked briefly at the |
(Feel free to ask if you have any questions about my comments, or what I was thinking.) |
I should say, I am planning to investigate pattern for inheritance of settings from "program" down into commands myself anyway for #951. So don't feel you have to solve that yourself, feel free to wait for a pattern for that part. |
Sorry for disappearing for a bit. I'm hoping to have have time this week to tackle your comments. |
No worries, thanks for update. I usually give people a month before taking other action. :-) |
Thanks for updates, I am excited to check them out. Might be a few days before I have enough time. |
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
Adds custom version description, custom help flags, custom help description. (Nice!) This is technically a minor version as new features that should be backwards compatible, but changes enough that we might be better to be cautious and roll it into v3 @abetomo ? |
I think that it is all right with the v2 release. |
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.
👍
I am wondering again whether overloading I came back to this because of a fresh report over confusion due to command description triggering git-style executable commands, reminding me that compact and "clever" can be too subtle and cause confusion for years! The two names I had come up with previously were No code changes wanted at this stage @idmontie, but I am thinking again about what will be best in longterm. |
This is a strong candidate for v3 as has passed two code reviews. I am leaning towards naming the custom help routine something different rather than overloading though. If I decide I want to go with that, would you like to do the work @idmontie ? (I am willing to make the changes, in which case I would invite you to review it.) |
@shadowspawn I can do that change if you provide the function name 👍 |
Thanks @idmontie. Settled on program
.helpOption('-c, --HELP', 'custom help message') |
Close tj#47. Add override for the help message by calling program.help(message). Add override for the version message by calling program.version(version, flag, message);
Sub-commands now inherit the help flags of their parent. These can be overriden by calling ".help" on the sub-commands. Added a test to cover these cases. Updated the example to also demonstrate this feature. Improved documentation on help and outputHelp functions for both JS and TypeScript.
1b58cf3
to
14f54c5
Compare
Thanks @idmontie. I am going to start merging to There are a couple of left-over bits in Thank you for your contributions. |
Minor edits from John Gee to typings added during squash.
Merged into v3 and will be included in that release. Closing to make it clear that should not be merged into master. FYI Ivan, I did a squash during manual merging, fixed the typings, and made you the author of the commit. Thank you for your contributions. |
Available now as a prerelease. See #1001 |
Close #47.
Add override for the help message by calling program.help(message).
Add override for the version message by calling
program.version(version, flag, message);