Skip to content

Commit

Permalink
feat: hidden options are now explicitly indicated using "hidden" flag (
Browse files Browse the repository at this point in the history
…yargs#962)

BREAKING CHANGE: previously hidden options were simply implied using a falsy description
  • Loading branch information
laggingreflex authored and bcoe committed Oct 14, 2017
1 parent 8c1d7bf commit 280d0d6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
33 changes: 31 additions & 2 deletions test/usage.js
Expand Up @@ -2314,10 +2314,12 @@ describe('usage tests', () => {
const r = checkUsage(() => yargs(['--help'])
.option('answer', {
type: 'string',
choices: ['yes', 'no', 'maybe']
choices: ['yes', 'no', 'maybe'],
hidden: true
})
.option('confidence', {
choices: [0, 25, 50, 75, 100]
choices: [0, 25, 50, 75, 100],
hidden: true
})
.wrap(null)
.argv
Expand Down Expand Up @@ -2698,4 +2700,31 @@ describe('usage tests', () => {
])
})
})

describe('hidden options', () => {
it('--help should display all options except for hidden ones', () => {
const r = checkUsage(() => yargs('--help')
.options({
foo: {
describe: 'FOO'
},
bar: {},
baz: {
describe: 'BAZ',
hidden: true
}
})
.argv
)

r.logs[0].split('\n').should.deep.equal([
'Options:',
' --help Show help [boolean]',
' --version Show version number [boolean]',
' --foo FOO',
' --bar',
''
])
})
})
})
2 changes: 1 addition & 1 deletion yargs.js
Expand Up @@ -647,7 +647,7 @@ function Yargs (processArgs, cwd, parentRequire) {
}

const desc = opt.describe || opt.description || opt.desc
if (desc) {
if (!opt.hidden) {
self.describe(key, desc)
}

Expand Down

0 comments on commit 280d0d6

Please sign in to comment.