You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
git-style subcommands mess up argument order when using boolean flags #508
varcommand=require('commander')varcmd=command.option('--dry-run','prints actions, but takes none').parse(process.argv)console.log('opts',cmd.opts())console.log('args',cmd.args)
changed the title [-]git-style subcommand mess up argument order when using boolean flags[/-][+]git-style subcommands mess up argument order when using boolean flags[/+]on Mar 12, 2016
const program = require('commander');
program
.command('sub <args...>')
.option('-a')
.action((args) => {
console.log(args);
})
program
.parse(process.argv);
$ node badParse.js sub foo bar
[ 'foo', 'bar' ]
$ node badParse.js sub -a foo bar
[ 'foo', 'bar' ]
$ node badParse.js sub foo -a bar
[ 'bar', 'foo' ]
Activity
[-]git-style subcommand mess up argument order when using boolean flags[/-][+]git-style subcommands mess up argument order when using boolean flags[/+]jmatsushita commentedon Mar 13, 2016
Ran into the same problem just now.
nukelytide commentedon Mar 14, 2017
I can confirm this issue as well.
stnever commentedon Feb 20, 2019
I can confirm this issue on commander@2.18.0 as well.
shadowspawn commentedon Aug 10, 2019
This was reported again in #962 which has some good reproduction examples and discussion.
shadowspawn commentedon Dec 29, 2019
Possible related, reported for action handler: #56 #75
shadowspawn commentedon Dec 29, 2019
Reproduced related issue with action handler:
shadowspawn commentedon Jan 7, 2020
Opened a PR to preserve argument order: #1138
shadowspawn commentedon Feb 1, 2020
The argument order is fixed in the published pre-release of Commander v5.0.0 (#1163)
shadowspawn commentedon Mar 14, 2020
Commander v5.0.0 has been released.
https://github.com/tj/commander.js/releases/tag/v5.0.0
fix(package): update commander to version 5.0.0
fix(package): update commander to version 5.0.0
fix(package): update commander to version 5.0.0
fix(package): update commander to version 5.0.0
fix(package): update commander to version 5.0.0