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

feat: --show-hidden #1061

Merged
merged 1 commit into from Mar 4, 2018
Merged

feat: --show-hidden #1061

merged 1 commit into from Mar 4, 2018

Conversation

laggingreflex
Copy link
Contributor

Adds a --show-hidden flag to show options defined with hidden: true property

Recap: (#962) Earlier, a fix was made to address the issue where .options({...}) without a description property did not show up up in --help. The fix introduced a new hidden: true property to truly hide an option from --help, and to show all other options (even without description property)

Issue with the fix: There was no way to show options defined with hidden:true property (they were hidden permanently)

Solution (this patch): This introduces a new flag: --show-hidden (pre-configured) which can be used to show those hidden options.

The default key for this new flag may also be custom configured with a new function property .showHidden('custom-show-hidden')

@Morishiri
Copy link
Contributor

The code looks fine, but maybe you could write some UT for that?

@laggingreflex laggingreflex force-pushed the fix/851-c branch 3 times, most recently from fc1d700 to 8e3d953 Compare January 27, 2018 13:03
@laggingreflex
Copy link
Contributor Author

@Morishiri done

Copy link
Member

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me 👍 but mind adding the showHidden method to the api docs?

Adds a `--show-hidden` flag to show options defined with `hidden: true` property

Recap: Earlier, a fix was made to address the issue where `.options({...})` without a `description` property did not show up up in `--help`. The fix introduced a new `hidden: true` property to truly hide an option from `--help`, and to show all other options (even without `description` property)

Issue with the fix: There was no way to show options defined with `hidden:true` property (they were hidden permanently)

Solution (this patch): This introduces a new flag: `--show-hidden` which is pre-configured. It can be used to show those hidden options.

The default key for this new flag may also be custom configured with a new function property `.showHidden()`
@laggingreflex
Copy link
Contributor Author

@bcoe done

@bcoe bcoe merged commit ea862ae into yargs:master Mar 4, 2018
@bcoe
Copy link
Member

bcoe commented Mar 4, 2018

@gajus @laggingreflex @Morishiri thanks for the help landing this feature, sorry that it took so long to get over the finish line.

@kopax
Copy link

kopax commented May 22, 2018

Hi, I was looking for such feature. I am using 11.0.0, I presume this have not been release yet right ?
When will it be?

@laggingreflex
Copy link
Contributor Author

It's released in 11.1.0 but there seems to be an issue regarding latest npm release.

Try installing/setting 11.1.0 version manually.

@kopax
Copy link

kopax commented May 22, 2018

@laggingreflex thanks, I have updated to 11.1.0.

I have the following options:

  .option('copyright-holder', {
    alias: 'c',
    describe: 'Change the default copyright-holder',
    hidden: true,
  })

Executing the cli with --help and --show-hidden did not work:

Options:
  --version   Show version number                                                          [boolean]
  --help      Show help                                                                    [boolean]

@laggingreflex
Copy link
Contributor Author

You also need to execute .showHidden()

@kopax
Copy link

kopax commented May 22, 2018

@laggingreflex so we must have this hidden program documented to everyone?
I rather not show some command to everyone, could be nice to have a .showHidden({ noHelp: true })

@laggingreflex
Copy link
Contributor Author

@kopax I'm not sure I understand, could you please elaborate with an example.

@kopax
Copy link

kopax commented May 23, 2018

@laggingreflex

Sure for example this use case:

I want to have a --change-copyright-holder options within a script. I am the only one who can do that, it's my license. I want to keep it hidden to everyone, using the hidden: true on my option, I can do it

I want to keep the --show-hidden for my self, doing .showHidden() will inform users of such hidden option.

@laggingreflex
Copy link
Contributor Author

@kopax If I understand correctly, what you tried earlier should work. I.e. without .showHidden() --help should show neither --show-hidden nor --copyright. --help --show-hidden should show --copyright.

If that doesn't work, or it's not what you wanted, could you please open a new detailed issue, possibly with a reproduction repo and expected vs. actual outputs.

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

Successfully merging this pull request may close these issues.

None yet

5 participants