Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function parse (args, opts) {
!checkAllAliases(key, flags.counts)) {
setArg(key, next)
i++
} else if (/true|false/.test(next)) {
} else if (/^(true|false)$/.test(next)) {
setArg(key, next)
i++
} else {
Expand Down
9 changes: 9 additions & 0 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ describe('yargs-parser', function () {
parse.should.have.property('_').and.deep.equal(['moo'])
})

it('should not set boolean options values if the next value only contains the words "true" or "false"', function () {
var parse = parser(['--verbose', 'aaatrueaaa', 'moo', '-t', 'aaafalseaaa'], {
boolean: ['t', 'verbose']
})
parse.should.have.property('verbose', true).and.be.a('boolean')
parse.should.have.property('t', true).and.be.a('boolean')
parse.should.have.property('_').and.deep.equal(['aaatrueaaa', 'moo', 'aaafalseaaa'])
})

it('should allow defining options as boolean in groups', function () {
var parse = parser([ '-x', '-z', 'one', 'two', 'three' ], {
boolean: ['x', 'y', 'z']
Expand Down