diff --git a/index.js b/index.js index 564cb2ed..8eecb628 100644 --- a/index.js +++ b/index.js @@ -540,7 +540,7 @@ function parse (args, opts) { o[key] = increment(o[key]) } else if (o[key] === undefined && checkAllAliases(key, flags.arrays)) { o[key] = Array.isArray(value) ? value : [value] - } else if (o[key] === undefined || checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) { + } else if (o[key] === undefined || checkAllAliases(key, flags.bools) || checkAllAliases(keys.join('.'), flags.bools) || checkAllAliases(key, flags.counts)) { o[key] = value } else if (Array.isArray(o[key])) { o[key].push(value) diff --git a/test/yargs-parser.js b/test/yargs-parser.js index dac993c9..f4fbeb7b 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -198,6 +198,18 @@ describe('yargs-parser', function () { parse.should.have.property('_').and.deep.equal(['one', 'two', 'three']) }) + it('should correctly parse dot-notation boolean flags', function () { + var parse = parser(['--nested', '--n.v', '--n.y', 'foo'], { + boolean: ['nested', 'n.v'] + }) + + parse.should.have.property('nested', true).and.be.a('boolean') + parse.should.have.property('n').and.deep.equal({ + v: true, + y: 'foo' + }) + }) + it('should preserve newlines in option values', function () { var args = parser(['-s', 'X\nX']) args.should.have.property('_').with.length(0)