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
options without description to not appear in --help #851
Comments
@gajus Yes, you're quite correct, but I believe this is intentional (or, at least, was at some point in the past). As you can see here, options are only included in help content if they (1) have a description, (2) are required, or (3) have a default value. I'm not sure when this rationale was determined or exactly why it is this way - I mean it kinda makes sense - but I believe yargs has been this way for as long as I've used it, which goes back to at least an early version of 3.x. Would you like to propose a change? Should yargs include all options in help content by default? Does it even make sense to have "hidden" or "undocumented" options? In the meantime, a quick workaround is to give each option a description. |
@bcoe What is the logic behind this? |
@gajus I believe the idea was that it would look ugly to have an argument with no description; and also it gives a way to provide hidden options; I'd be inclined to revisit this decision; if you've explicitly created an option, I think we should show it; one question though, should we warn if no description is provided? |
No. Whats the reason you think it should? Good parameter names is like good variable naming. If you name it well, you don't need a description, e.g. This wouldn't even be a breaking change. The docs say:
Fine. If |
I was just trying to make it work when i stumbled upon something that can solve this case, but, i think that it shouldn't have been solved in this way. if instead of let args = yargs.usage('$0 <cmd> [args]')
.describe(`weird`)
.help()
.argv;
// Try --help
// Then try --weird and see it parsed as an option
console.log('args', args); |
@DiegoZoracKy @gajus I like the idea of requiring that folks explicitly set describe to would happily accept a patch. |
to hide from the help menu, you can pass .command('foo', false, ...) |
yargs@7.0.2
Note the missing
forward
option.The text was updated successfully, but these errors were encountered: