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
fix: show hidden options in help #962
Conversation
yargs.js
Outdated
@@ -644,9 +645,11 @@ function Yargs (processArgs, cwd, parentRequire) { | |||
self.skipValidation(key) | |||
} | |||
|
|||
const desc = opt.describe || opt.description || opt.desc | |||
const desc = 'describe' in opt ? opt.describe : 'description' in opt ? opt.description : 'desc' in opt ? opt.desc : undefined |
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.
Ternary operator which is nested 3 times is really hard to understand. I think it will be better if it will be splitted in some more cases to be easier to read.
31b784e
to
80fd2a3
Compare
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.
Looks good to me, do you sign off too @Morishiri?
Having second thoughts on this. Currently it shows options if their description is set to false. (as per your comment @bcoe). Would it be better if it shows options when description is left blank, and doesn't show when it's set to false? This would also be more inline with the current docs (as pointed out by @gajus)
Or would that break existing usage? |
👍 |
@laggingreflex good catch; I'm with both you and @gajus on this. Let's show the option if an empty string is provided for the description, hide on Sound reasonable? |
I still think that an explicit option should be used to make a parameter hidden. All this convention based behaviour is tricky to document/ remember. As long as option is provided, it should be visible, unless that option contains configuration .options({
foo: {
describe: 'FOO'
},
bar: {},
baz: {
describe: 'BAZ',
hidden: true
}
}); With this configuration,
The benefits of this approach:
|
@gajus this argument seems reasonable to me, and I think we're inching up on a new major release of yargs any ways, with some of the work I've been doing around command parsing/number coercion. @laggingreflex thoughts on the options discussed above? |
4e42b8a
to
118a91b
Compare
@laggingreflex this looks good to me; any idea why test coverage dropped so much? |
I was testing with Also this doesn't yet implement |
@laggingreflex 👍 I'm working on a pretty big |
Instead of yargs.showHelp('log', {showHidden: [true|false]}) This gives the user more control. Like maybe they wouldn't want to show hidden commands at all. Or maybe they'd want it behind a custom flag. This way they can implement it themselves. It however require that the user implements the const argv = yargs
.options({
baz: {
describe: 'BAZ',
hidden: true
},
'show-hidden': {
describe: 'Show hidden options',
type: 'boolean'
},
})
.help(false)
.argv
if (yargs.help) {
yargs.showHelp('log', {hidden: argv.showHidden})
} |
8c843fb
to
d3b053e
Compare
@laggingreflex I'd be tempted to discuss |
d3b053e
to
85a996e
Compare
I've undone the last commit and I'll move it to a separate issue/pr. This now only enables the |
Options with
description: false
will now show up helpfixes #851