Comparing version 0.1.6 to 0.1.7
17
index.js
@@ -47,2 +47,3 @@ module.exports = Argv; | ||
var value = typeof val !== 'string' || isNaN(num) ? val : num; | ||
if (flags.strings[key]) value = val; | ||
@@ -60,3 +61,3 @@ if (key in self.argv) { | ||
var flags = { bools : {} }; | ||
var flags = { bools : {}, strings : {} }; | ||
@@ -83,2 +84,16 @@ self.boolean = function (bools) { | ||
self.string = function (strings) { | ||
if (!Array.isArray(strings)) { | ||
strings = [].slice.call(arguments); | ||
} | ||
strings.forEach(function (name) { | ||
flags.strings[name] = true; | ||
}); | ||
rescan(); | ||
return self; | ||
}; | ||
function rescan () { | ||
@@ -85,0 +100,0 @@ self.argv = { _ : [], $0 : self.$0 }; |
{ | ||
"name" : "optimist", | ||
"version" : "0.1.6", | ||
"version" : "0.1.7", | ||
"description" : "Light-weight option parsing with an argv hash. No optstrings attached.", | ||
@@ -12,5 +12,8 @@ "main" : "./index.js", | ||
"argument", | ||
"args", | ||
"option", | ||
"parser", | ||
"parsing" | ||
"parsing", | ||
"cli", | ||
"command" | ||
], | ||
@@ -17,0 +20,0 @@ "author" : { |
// coffee script style arguments where process.argv is .splice(2)'d | ||
var fs = require('fs'); | ||
var Script = process.binding('evals').Script; | ||
var Hash = require('traverse/hash'); | ||
var Hash = require('hashish'); | ||
@@ -6,0 +6,0 @@ exports.coffee = function (assert) { |
var optimist = require('optimist'); | ||
var assert = require('assert'); | ||
@@ -146,2 +147,3 @@ exports['short boolean'] = function (assert) { | ||
'-w', '10f', | ||
'--hex', '0xdeadbeef', | ||
'789', | ||
@@ -154,2 +156,3 @@ ]); | ||
w : '10f', | ||
hex : 0xdeadbeef, | ||
_ : [ 789 ], | ||
@@ -162,2 +165,3 @@ $0 : 'expresso' | ||
assert.eql(typeof argv.w, 'string'); | ||
assert.eql(typeof argv.hex, 'number'); | ||
assert.eql(typeof argv._[0], 'number'); | ||
@@ -188,1 +192,11 @@ }; | ||
}; | ||
exports.strings = function () { | ||
var s = optimist([ '-s', '0001234' ]).string('s').argv.s; | ||
assert.eql(s, '0001234'); | ||
assert.eql(typeof s, 'string'); | ||
var x = optimist([ '-x', '56' ]).string('x').argv.x; | ||
assert.eql(x, '56'); | ||
assert.eql(typeof x, 'string'); | ||
}; |
@@ -1,2 +0,2 @@ | ||
var Hash = require('traverse/hash'); | ||
var Hash = require('hashish'); | ||
var optimist = require('optimist'); | ||
@@ -3,0 +3,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27952
22
722