Skip to content
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

Make auto help optional #242

Closed
ajcrites opened this issue Aug 26, 2014 · 7 comments
Closed

Make auto help optional #242

ajcrites opened this issue Aug 26, 2014 · 7 comments

Comments

@ajcrites
Copy link

There may be some circumstances where --help or -h should perform their .on("--help") duties, but we may not want to print out the automatic help message.

.help is already a method, so I propose a method like .helpFlags that you could include in the usual parse chain that would take overriding help flags as an argument. --help and -h would still work by default, but you could do .helpFlags("-a, --ayudar") to use those instead or even .helpFlags() to prevent anything from outputting the help automatically.

@thethomaseffect
Copy link
Collaborator

We've discussed a plugin system for commander, while I haven't had a chance to get much done on it recently my plan is for built-ins such as --version and --help to be implemented as plugins that can be turned off or replaced easily. The internal code in the loader might look something like this:

// plugins is a dictionary mapping names to functions
Command.prototype.help = plugins['help'] || defaultHelp // We use an anonymous function right now

Right now help is a little more complex than this but hopefully we'll be able make it this simple. Lots of people have requested more flexible built-ins so this should let people do whatever they need without having to change commanders code and should provide a nice way to test new functionality before adding it to the core codebase.

@Globegitter
Copy link
Contributor

That is my main point currently with commander - an otherwise great library, so this feature would be really helpful.

@thethomaseffect
Copy link
Collaborator

I'm working on this feature right now but it's a little more involved than I imagined, might be a while before I get to the pull request

@shadowspawn
Copy link
Collaborator

Not currently planning a plugin system, but keeping this bug open for now as an early request for being able to override automatic help behaviour.

@shadowspawn
Copy link
Collaborator

There is not currently a way to disable the auto-help, but from v3 there is .helpOption to customise the help flags and message.
https://github.com/tj/commander.js/releases/tag/v3.0.0

This issue has not had any activity in years. It isn't likely to get acted on due to this report.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

@RonWang
Copy link

RonWang commented Aug 18, 2019

Still need this feature in great demand, as we want to add ASCii art for our CLI name at the front of the help message, and correct some help message auto-generated but not useful for our case. Appending on '--help' event won't help. Isn't this not supported in the short term?

@shadowspawn
Copy link
Collaborator

Commander v6.1 allows allows disabling the built-in help option: #1325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants