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

Prevent/override automatic help generation #1215

Closed
b3nk3 opened this issue Mar 12, 2020 · 8 comments
Closed

Prevent/override automatic help generation #1215

b3nk3 opened this issue Mar 12, 2020 · 8 comments

Comments

@b3nk3
Copy link

b3nk3 commented Mar 12, 2020

I am successfully utilising the custom help, as per README.md however, I would like to prevent the output of the automatically generated help.

Is there a way to do this?

@shadowspawn
Copy link
Collaborator

So do you want the help option support (e.g. for --help), but don't want the automatically generated help displayed as part of the processing?

There is not currently explicit support for that.

I have a tentative idea for the future which would allow this, feedback welcome:
#1023 (comment)

@b3nk3
Copy link
Author

b3nk3 commented Mar 13, 2020

Yes, precisely that.

I like the idea of the separation you have outlined.

I would also include an option, as a boolean, to toggle auto generated help?

Happy to work on this with you, just need to get an understanding of how the whole thing works :)

@shadowspawn
Copy link
Collaborator

shadowspawn commented Mar 13, 2020

As a work-around, you can override the help by defining your own option using the same flags. This isn't a complete solution as the autogenerated help would show both, but this might not affect you since you are displaying custom help anyway!

e.g.

const { Command } = require('commander');
program = new Command();

program
  .storeOptionsAsProperties(false)
  .option('-h, --help', 'show my custom help')
  .parse(process.argv);

const options = program.opts();
if (options.help) {
  console.log('show my custom help');
}
$ node index.js -h
show my custom help

@b3nk3
Copy link
Author

b3nk3 commented Mar 16, 2020

This is helpful and enough for my use case. Still happy to help, if you need hand.

@shadowspawn
Copy link
Collaborator

Thanks. I am planning to go through the issues and collect the help related issues before making any changes, to look for the more popular or common issues that come up. I'll post here when I do.

@shadowspawn
Copy link
Collaborator

(Collected help issues in #1225.)

@shadowspawn
Copy link
Collaborator

No additional likes on this issue in particular, closing in favour of #1225 with collected issues.

Thank you for your contributions.

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants