Skip to content

Commit

Permalink
fix: positional arguments were not being handled appropriately by par…
Browse files Browse the repository at this point in the history
…se() (yargs#559)
  • Loading branch information
bcoe committed Jul 16, 2016
1 parent 8d7585c commit 063a866
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/command.js
Expand Up @@ -485,4 +485,12 @@ describe('Command', function () {
output.should.include('bar')
output.should.not.include('foo')
})

// addresses https://github.com/yargs/yargs/issues/558
it('handles positional arguments if command is invoked using .parse()', function () {
var y = yargs([])
.command('foo <second>', 'the foo command', {})
var argv = y.parse(['foo', 'bar'])
argv.second.should.equal('bar')
})
})
1 change: 1 addition & 0 deletions yargs.js
Expand Up @@ -373,6 +373,7 @@ function Yargs (processArgs, cwd, parentRequire) {
}

self.parse = function (args, shortCircuit) {
if (!shortCircuit) processArgs = args
return parseArgs(args, shortCircuit)
}

Expand Down

0 comments on commit 063a866

Please sign in to comment.