Comparing version 0.1.0 to 0.1.1
@@ -5,2 +5,8 @@ # commandos Change Log | ||
## [0.1.1] - Dec 30, 2017 | ||
### Fixed | ||
CLI sub-expression like `--=value` will be parsed to `{ '-': 'value' }` before. However, it is really ambiguous. Since this version, an exception will be thrownm in such cases. | ||
## [0.1.0] - Dec 30, 2017 | ||
@@ -7,0 +13,0 @@ |
@@ -15,3 +15,3 @@ { | ||
"name": "commandos", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"main": "index.js", | ||
@@ -18,0 +18,0 @@ "keywords": [ |
@@ -268,3 +268,3 @@ 'use strict'; | ||
args.forEach(arg => { | ||
if (/^(-{1,2})(no-)?([^=]+)(=(.+))?$/i.test(arg)) { | ||
if (/^(-{1,2})(no-)?([^=]*)(=(.+))?$/i.test(arg)) { | ||
let dash = RegExp.$1; | ||
@@ -275,3 +275,6 @@ let no = RegExp.$2; | ||
if (no) { | ||
if (name.length == 0) { | ||
throw new Error(`incomprehensible option: ${arg}`); | ||
} | ||
else if (no) { | ||
if (dash.length == 1 || value !== true) { | ||
@@ -278,0 +281,0 @@ throw new Error(`incomprehensible option: ${arg}`); |
@@ -107,3 +107,3 @@ # commandos | ||
commandos.parse('foo -n JACK -g male', settings); | ||
commandos.parse('foo -n JACK -g male', settings); | ||
// RETURN { name, gender, $ } | ||
@@ -124,3 +124,3 @@ ``` | ||
}; | ||
commandos.parse('foo -n JACK -g male', settings); | ||
commandos.parse('foo -n JACK -g male', settings); | ||
// RETURN { $ } | ||
@@ -147,3 +147,3 @@ // The first option group matched, becuase it does NOT require any options. | ||
A standard *definition of an option* (item of array *optionDefinitions* or *settings.options*) SHOULD be an object or a string. It may be an object made up of following attributes: | ||
A standard *definition of an option* (item of array *optionDefinitions* or *settings.options*) SHOULD be an object or a string. It may be an object made up of following attributes: | ||
@@ -217,2 +217,2 @@ * __name__ *string* | ||
* [optimist](https://www.npmjs.com/package/optimist) | ||
* [yargs](https://www.npmjs.com/package/yargs) | ||
* [yargs](https://www.npmjs.com/package/yargs) |
@@ -71,2 +71,7 @@ 'use strict'; | ||
it('--=value SHOULD throw exception', () => { | ||
let cmdtext = 'foo --=male'; | ||
assert.throws(ex => parseCommand(cmdtext)); | ||
}); | ||
it('--no-<option> SHOULD NOT be assigned', () => { | ||
@@ -258,6 +263,9 @@ let cmdtext = 'foo --no-gender=male'; | ||
let cmdtext = 'foo -v 1.0 -v 2.0 -v 3.0'; | ||
let options = [ '-v MULTIPLE' ]; | ||
let options = [ '-v MULTIPLE', '-n MULTIPLE' ]; | ||
let cmd = parseCommand(cmdtext, options); | ||
assert(cmd.v instanceof Array); | ||
assert.equal(cmd.v.length, 3); | ||
assert(!cmd.hasOwnProperty('n')); | ||
}); | ||
@@ -264,0 +272,0 @@ |
32432
646
215