optimist
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -347,3 +347,3 @@ var path = require('path'); | ||
} | ||
else if (/true|false/.test(next)) { | ||
else if (/^(true|false)$/.test(next)) { | ||
setArg(key, next === 'true'); | ||
@@ -350,0 +350,0 @@ i++; |
{ | ||
"name" : "optimist", | ||
"version" : "0.3.4", | ||
"version" : "0.3.5", | ||
"description" : "Light-weight option parsing with an argv hash. No optstrings attached.", | ||
@@ -5,0 +5,0 @@ "main" : "./index.js", |
@@ -5,7 +5,7 @@ var optimist = require('../index'); | ||
var expresso = 'node ./parse.js'; | ||
var $0 = 'node ./' + path.relative(process.cwd(), __filename); | ||
test('short boolean', function (t) { | ||
var parse = optimist.parse([ '-b' ]); | ||
t.same(parse, { b : true, _ : [], $0 : expresso }); | ||
t.same(parse, { b : true, _ : [], $0 : $0 }); | ||
t.same(typeof parse.b, 'boolean'); | ||
@@ -18,3 +18,3 @@ t.end(); | ||
optimist.parse([ '--bool' ]), | ||
{ bool : true, _ : [], $0 : expresso } | ||
{ bool : true, _ : [], $0 : $0 } | ||
); | ||
@@ -27,3 +27,3 @@ t.end(); | ||
optimist.parse([ 'foo', 'bar', 'baz' ]), | ||
{ _ : [ 'foo', 'bar', 'baz' ], $0 : expresso } | ||
{ _ : [ 'foo', 'bar', 'baz' ], $0 : $0 } | ||
); | ||
@@ -36,3 +36,3 @@ t.end(); | ||
optimist.parse([ '-cats' ]), | ||
{ c : true, a : true, t : true, s : true, _ : [], $0 : expresso } | ||
{ c : true, a : true, t : true, s : true, _ : [], $0 : $0 } | ||
); | ||
@@ -45,3 +45,3 @@ t.end(); | ||
optimist.parse([ '-cats', 'meow' ]), | ||
{ c : true, a : true, t : true, s : 'meow', _ : [], $0 : expresso } | ||
{ c : true, a : true, t : true, s : 'meow', _ : [], $0 : $0 } | ||
); | ||
@@ -54,3 +54,3 @@ t.end(); | ||
optimist.parse([ '-h', 'localhost' ]), | ||
{ h : 'localhost', _ : [], $0 : expresso } | ||
{ h : 'localhost', _ : [], $0 : $0 } | ||
); | ||
@@ -63,3 +63,3 @@ t.end(); | ||
optimist.parse([ '-h', 'localhost', '-p', '555' ]), | ||
{ h : 'localhost', p : 555, _ : [], $0 : expresso } | ||
{ h : 'localhost', p : 555, _ : [], $0 : $0 } | ||
); | ||
@@ -72,3 +72,3 @@ t.end(); | ||
optimist.parse([ '--pow', 'xixxle' ]), | ||
{ pow : 'xixxle', _ : [], $0 : expresso } | ||
{ pow : 'xixxle', _ : [], $0 : $0 } | ||
); | ||
@@ -81,3 +81,3 @@ t.end(); | ||
optimist.parse([ '--pow=xixxle' ]), | ||
{ pow : 'xixxle', _ : [], $0 : expresso } | ||
{ pow : 'xixxle', _ : [], $0 : $0 } | ||
); | ||
@@ -90,3 +90,3 @@ t.end() | ||
optimist.parse([ '--host', 'localhost', '--port', '555' ]), | ||
{ host : 'localhost', port : 555, _ : [], $0 : expresso } | ||
{ host : 'localhost', port : 555, _ : [], $0 : $0 } | ||
); | ||
@@ -99,3 +99,3 @@ t.end(); | ||
optimist.parse([ '--host=localhost', '--port=555' ]), | ||
{ host : 'localhost', port : 555, _ : [], $0 : expresso } | ||
{ host : 'localhost', port : 555, _ : [], $0 : $0 } | ||
); | ||
@@ -110,3 +110,3 @@ t.end(); | ||
f : true, p : 555, h : 'localhost', | ||
_ : [ 'script.js' ], $0 : expresso, | ||
_ : [ 'script.js' ], $0 : $0, | ||
} | ||
@@ -122,3 +122,3 @@ ); | ||
f : true, p : 555, h : 'localhost', | ||
_ : [ 'script.js' ], $0 : expresso, | ||
_ : [ 'script.js' ], $0 : $0, | ||
} | ||
@@ -132,3 +132,3 @@ ); | ||
optimist.parse([ '--no-moo' ]), | ||
{ moo : false, _ : [], $0 : expresso } | ||
{ moo : false, _ : [], $0 : $0 } | ||
); | ||
@@ -141,3 +141,3 @@ t.end(); | ||
optimist.parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]), | ||
{ v : ['a','b','c'], _ : [], $0 : expresso } | ||
{ v : ['a','b','c'], _ : [], $0 : $0 } | ||
); | ||
@@ -169,3 +169,3 @@ t.end(); | ||
_ : [ 'bare', '--not-a-flag', 'eek' ], | ||
$0 : expresso | ||
$0 : $0 | ||
} | ||
@@ -192,3 +192,3 @@ ); | ||
_ : [ 789 ], | ||
$0 : expresso | ||
$0 : $0 | ||
}); | ||
@@ -206,3 +206,3 @@ t.same(typeof argv.x, 'number'); | ||
var parse = optimist([ '-t', 'moo' ]).boolean(['t']).argv; | ||
t.same(parse, { t : true, _ : [ 'moo' ], $0 : expresso }); | ||
t.same(parse, { t : true, _ : [ 'moo' ], $0 : $0 }); | ||
t.same(typeof parse.t, 'boolean'); | ||
@@ -220,3 +220,3 @@ t.end(); | ||
_: ['moo'], | ||
$0 : expresso | ||
$0 : $0 | ||
}); | ||
@@ -239,3 +239,3 @@ | ||
_: ['moo'], | ||
$0 : expresso | ||
$0 : $0 | ||
}); | ||
@@ -258,3 +258,3 @@ | ||
_ : [ 'one', 'two', 'three' ], | ||
$0 : expresso | ||
$0 : $0 | ||
}); | ||
@@ -292,7 +292,7 @@ | ||
optimist.parse([ '-I/foo/bar/baz' ]), | ||
{ I : '/foo/bar/baz', _ : [], $0 : expresso } | ||
{ I : '/foo/bar/baz', _ : [], $0 : $0 } | ||
); | ||
t.same( | ||
optimist.parse([ '-xyz/foo/bar/baz' ]), | ||
{ x : true, y : true, z : '/foo/bar/baz', _ : [], $0 : expresso } | ||
{ x : true, y : true, z : '/foo/bar/baz', _ : [], $0 : $0 } | ||
); | ||
@@ -386,3 +386,3 @@ t.end(); | ||
'_': [ 'derp' ], | ||
'$0': expresso, | ||
'$0': $0, | ||
}; | ||
@@ -409,3 +409,3 @@ | ||
'_': [ 'derp' ], | ||
'$0': expresso, | ||
'$0': $0, | ||
}; | ||
@@ -437,3 +437,3 @@ | ||
'_': [ ], | ||
'$0': expresso, | ||
'$0': $0, | ||
}; | ||
@@ -446,1 +446,14 @@ | ||
// regression, see https://github.com/substack/node-optimist/issues/71 | ||
test('boolean and --x=true', function(t) { | ||
var parsed = optimist(['--boool', '--other=true']).boolean('boool').argv; | ||
t.same(parsed.boool, true); | ||
t.same(parsed.other, 'true'); | ||
parsed = optimist(['--boool', '--other=false']).boolean('boool').argv; | ||
t.same(parsed.boool, true); | ||
t.same(parsed.other, 'false'); | ||
t.end(); | ||
}); |
Sorry, the diff of this file is not supported yet
48595
26
1253