electron
Advanced tools
Comparing version 0.2.1 to 0.3.0
0.3.0 / 2012-10-07 | ||
================== | ||
* update comments to reflect multiword params | ||
* add support for multiword argv paramters and tests | ||
0.2.1 / 2012-06-11 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -30,3 +30,3 @@ /*! | ||
exports.version = '0.2.0'; | ||
exports.version = '0.3.0'; | ||
@@ -33,0 +33,0 @@ /*! |
@@ -61,2 +61,10 @@ /*! | ||
* | ||
* You can also specify paramters with multiple words by surrounding the | ||
* phrase with double-quotes. | ||
* | ||
* // $ node cli.js --say "hello universe" | ||
* argv.params === { | ||
* say: 'hello universe' | ||
* }; | ||
* | ||
* @header Argument Parsing Utility | ||
@@ -148,3 +156,4 @@ */ | ||
, parts = args.slice(2) | ||
, input = this; | ||
, input = this | ||
, isStr = false; | ||
@@ -158,2 +167,6 @@ function checkParamKey () { | ||
function appendStr (key, str) { | ||
input.params[key] += ' ' + str; | ||
} | ||
parts.forEach(function (part) { | ||
@@ -189,4 +202,15 @@ if (part.substr(0, 2) === '--') { | ||
if (param_key !== null) { | ||
input.params[param_key] = part; | ||
param_key = null; | ||
if (part[0] === '"') { | ||
isStr = true; | ||
input.params[param_key] = part.substr(1); | ||
} else if (isStr && part[part.length - 1] === '"') { | ||
isStr = false; | ||
appendStr(param_key, part.substr(0, part.length - 1)); | ||
param_key = null; | ||
} else if (isStr) { | ||
appendStr(param_key, part); | ||
} else { | ||
input.params[param_key] = part; | ||
param_key = null; | ||
} | ||
} else { | ||
@@ -193,0 +217,0 @@ input.commands.push(part); |
@@ -8,3 +8,3 @@ { | ||
"license": "MIT", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type": "git", |
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
37387
1097