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
How to display help when someone types an invalid option? #919
Comments
This came up previously also in #482. |
Does this help?
|
An answer was provided, and no further activity in a month. Closing this as resolved. Feel free to open a new issue if it comes up again, with new information and renewed interest. |
In case someone stumbles here, this is how to show help when an invalid option was passed: const cli = new commander.Command()
cli
.description('...')
.option(...)
// ...
.exitOverride(err => {
// If an unknown option was passed, show help.
if (err.code === 'commander.unknownOption') cli.help();
});
cli.parse() |
Merged
This comment has been minimized.
This comment has been minimized.
Related: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If someone types in an option that doesn't exist, i want to display the
--help
text similarly to usingprogram.help()
.Where can i listen for errors such as this:
$ ./createUser -V error: unknown option `-V'
So that I can call
program.help()
?The text was updated successfully, but these errors were encountered: