Skip to content

Commit

Permalink
allow - as positional argument
Browse files Browse the repository at this point in the history
For representing stdin (or whatever else)
  • Loading branch information
michaelficarra authored and isaacs committed Jul 17, 2013
1 parent 5a59144 commit 649d969
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/nopt.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function parse (args, data, remain, types, shorthands) {
break
}
var hadEq = false
if (arg.charAt(0) === "-") {
if (arg.charAt(0) === "-" && arg.length > 1) {
if (arg.indexOf("=") !== -1) {
hadEq = true
var v = arg.split("=")
Expand Down Expand Up @@ -580,6 +580,16 @@ var assert = require("assert")
,[]
,{clear:Boolean,con:Boolean,len:Boolean,exp:Boolean,add:Boolean,rep:Boolean}
,{c:"--con",l:"--len",e:"--exp",a:"--add",r:"--rep"}]
,["--file -"
,{"file":"-"}
,[]
,{file:String}
,{}]
,["--file -"
,{"file":true}
,["-"]
,{file:Boolean}
,{}]
].forEach(function (test) {
var argv = test[0].split(/\s+/)
, opts = test[1]
Expand Down

0 comments on commit 649d969

Please sign in to comment.