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

[feature request] hide default value and flag type on individual option #2299

Open
ljharb opened this issue Feb 13, 2023 · 4 comments
Open

Comments

@ljharb
Copy link
Contributor

ljharb commented Feb 13, 2023

#1145 / #2153 / #2156 implemented an "all or nothing" way to hide this, but the use case I've had is to hide the default value, and/or the flag type, on a specific value.

In other words, I want to be able to override the global setting per-option.

@bcoe
Copy link
Member

bcoe commented Feb 13, 2023

@ljharb I'm wondering if @jly36963's approach could be extended to accept a map rather than a boolean option.

@ljharb
Copy link
Contributor Author

ljharb commented Feb 13, 2023

Sure, that's fine! As long as it's configurable per-option I'm happy :-)

Since it doesn't affect the types of the option values, there's no argument to keep it in the .option invocation either, I think.

@Nantris
Copy link

Nantris commented Feb 14, 2023

Also interested in this functionality.

@shadowspawn
Copy link
Member

This isn't a full solution, but there is a partial solution for a "secret" in a default value (interesting case):

const yargs = require('yargs/yargs');

const argv = yargs(process.argv.slice(2))
    .option('user', { type: 'string' })
    .option('password', { type: 'string', default: 'super-secret', defaultDescription: 'REDACTED' })
    .parse();

console.log(argv);
 % node index.js --help
Options:
  --help      Show help                                                [boolean]
  --version   Show version number                                      [boolean]
  --user                                                                [string]
  --password                                        [string] [default: REDACTED]

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

No branches or pull requests

4 participants