Skip to content

Commit

Permalink
Merge branch 'miyajan-allow-hyphen-with-subcommand' into release/3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn committed Jun 23, 2019
2 parents b302e43 + 862e260 commit 76fea4a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -756,7 +756,7 @@ Command.prototype.parseOptions = function(argv) {
// If the next argument looks like it might be
// an argument for this option, we pass it on.
// If it isn't, then it'll simply be ignored
if ((i + 1) < argv.length && argv[i + 1][0] !== '-') {
if ((i + 1) < argv.length && (argv[i + 1][0] !== '-' || argv[i + 1] === '-')) {
unknownOptions.push(argv[++i]);
}
continue;
Expand Down
21 changes: 21 additions & 0 deletions test/test.options.subcommand-hyphen.js
@@ -0,0 +1,21 @@
/**
* Module dependencies.
*/

var program = require('../')
, should = require('should');

program
.command('subcommand')
.description('description')
.option('-a, --alpha <a>', 'hyphen')
.option('-b, --bravo <b>', 'hyphen')
.option('-c, --charlie <c>', 'hyphen')
.action(function (options) {
});

program.parse('node test subcommand -a - --bravo - --charlie=-'.split(' '));

program.commands[0].alpha.should.equal('-');
program.commands[0].bravo.should.equal('-');
program.commands[0].charlie.should.equal('-');

0 comments on commit 76fea4a

Please sign in to comment.