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

Show hidden options #974

Closed
wants to merge 1 commit into from
Closed

Conversation

laggingreflex
Copy link
Contributor

In #962 a new option was added {hidden: true} that hides an option from --help (instead of by omitting the description)

To show these hidden options, one of the suggestion was to use --yargs-show-hidden (@gajus).

How about instead, modify the showHelp like this:

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 --help themselves too:

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})
}

Adds an `opts` agument to `showHelp`

Currently, to enable showing hidden options:

```js
showHelp('log', {hidden: [true|false]})
```
@bcoe
Copy link
Member

bcoe commented Oct 17, 2017

@laggingreflex I feel like it would potentially limit the number of folks who find this feature, by forcing a user to handle the help output themselves -- it also means that features like validation are a bit less interesting; I'm not the biggest fan of adding --yargs-show-hidden either, as I think it exposes a bit too much of yargs' internals.

I'm heads down trying to get a few more things patched for yargs@10.x; but let's sit on this for a bit and figure out something soon.

@bcoe
Copy link
Member

bcoe commented Nov 23, 2017

@laggingreflex coming back to this issue after putting it down for a bit; I think that the suggestion of:

yargs.showHelp('log', {showHidden: [true|false]})

is pretty reasonable -- any interest in rebasing with this functionality?

@bcoe bcoe added the triaged label Nov 23, 2017
@gajus
Copy link
Contributor

gajus commented Nov 23, 2017

is pretty reasonable -- any interest in rebasing with this functionality?

I don't think it is optimal.

It requires code change to change CLI behaviour.

Users will opt-in to use an arbitrary environment variable to control this feature instead, e.g.

yargs.showHelp('log', {showHidden: process.env.MY_SHOW_HIDDEN})

Hidden options is yargs feature and as such yargs should provide a standardised way to control the behaviour instead of "outsourcing" the decision to the consumers.

@bcoe
Copy link
Member

bcoe commented Nov 23, 2017

@gajus I dislike that having a command line argument like --yargs-show-hidden is a leaky abstraction. People consuming foo-library shouldn't need to know that it's yargs behind the scenes.

Perhaps there's an argument --show-hidden, which only takes effect if --help has also been called? That seems like it would be unlikely to collide with other CLI applications.

@gajus
Copy link
Contributor

gajus commented Nov 23, 2017

@gajus I dislike that having a command line argument like --yargs-show-hidden is a leaky abstraction. People consuming foo-library shouldn't need to know that it's yargs behind the scenes.

You could argue the same about --help.

Are you specifically opposing yargs name appearing?

--show-hidden or --show-hidden-options sounds generic enough that it will unlikely to clash.

@bcoe
Copy link
Member

bcoe commented Dec 14, 2017

@gajus I'm specifically objecting to the --yargs prefix; I think a --show-hidden flag would be a good approach.

@laggingreflex, @gajus would either of you like to see this over the finish line? Otherwise I hopefully will carve some time for open source out over the holiday.

@laggingreflex
Copy link
Contributor Author

Superseded by #1061

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

Successfully merging this pull request may close these issues.

None yet

3 participants