diff --git a/index.js b/index.js index efdd577c3..b24a31cd9 100644 --- a/index.js +++ b/index.js @@ -737,7 +737,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 (argv[i+1] && '-' != argv[i+1][0]) { + if (argv[i+1] && ('-' != argv[i+1][0] || '-' === argv[i+1])) { unknownOptions.push(argv[++i]); } continue; diff --git a/test/test.options.subcommand-hyphen.js b/test/test.options.subcommand-hyphen.js new file mode 100644 index 000000000..14d9276cf --- /dev/null +++ b/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 ', 'hyphen') + .option('-b, --bravo ', 'hyphen') + .option('-c, --charlie ', '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('-');