minimist-subcommand
Advanced tools
Comparing version 1.0.0 to 2.0.0
15
index.js
@@ -1,4 +0,1 @@ | ||
var tv4 = require('tv4'); | ||
var COMMAND_JSON_SCHEMA = { | ||
@@ -30,9 +27,3 @@ definitions: { | ||
module.exports = function parseCommands(schema, argv) { | ||
var validated = tv4.validateResult(schema, COMMAND_JSON_SCHEMA); | ||
if (validated.valid === false) { | ||
throw new Error(validated.error); | ||
} | ||
function parseCommands(schema, argv) { | ||
function popCommandRecursively(currentSchema, currentArgv, parsedCommands) { | ||
@@ -84,1 +75,5 @@ | ||
}; | ||
parseCommands.COMMAND_JSON_SCHEMA = COMMAND_JSON_SCHEMA; | ||
module.exports = parseCommands; |
{ | ||
"name": "minimist-subcommand", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "A simple sub-command parser for minimist", | ||
@@ -26,10 +26,10 @@ "main": "index.js", | ||
"engines": { | ||
"node": ">=0.10" | ||
"node": ">=6", | ||
"npm": ">=3" | ||
}, | ||
"dependencies": { | ||
"tv4": "1.2.7" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"minimist": "1.2.0", | ||
"mocha": "2.3.3" | ||
"mocha": "2.3.3", | ||
"tv4": "^1.3.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "files": [ |
@@ -136,4 +136,18 @@ # minimist-subcommand | ||
## Command Schema | ||
## Command's Schema | ||
Please, look at [JSON Schema in source code](https://github.com/kjirou/minimist-subcommand/blob/master/index.js#L4) now. | ||
If you want to check schema of `commandDefinition`, please use `COMMAND_JSON_SCHEMA`. | ||
```js | ||
var COMMAND_JSON_SCHEMA = require('minimist-subcommand').COMMAND_JSON_SCHEMA; | ||
var commandDefinition = { | ||
commands: { | ||
foo: null, | ||
bar: null | ||
} | ||
}; | ||
// I will leave it to the judgment of the user. | ||
someJsonSchemaLibrary.validate(COMMAND_JSON_SCHEMA, commandDefinition); | ||
``` |
var assert = require('assert'); | ||
var minimist = require('minimist'); | ||
var tv4 = require('tv4'); | ||
var parseCommands = require('../index'); | ||
var COMMAND_JSON_SCHEMA = parseCommands.COMMAND_JSON_SCHEMA; | ||
@@ -118,5 +120,5 @@ | ||
context('schema validation', function() { | ||
context('COMMAND_JSON_SCHEMA', function() { | ||
it('should be', function() { | ||
it('can be used for JSON Schema', function() { | ||
var schema; | ||
@@ -130,5 +132,3 @@ | ||
}; | ||
assert.throws(function() { | ||
parseCommands(schema, []); | ||
}, /ValidationError/); | ||
assert.strictEqual(tv4.validateResult(schema, COMMAND_JSON_SCHEMA).valid, false); | ||
@@ -140,5 +140,3 @@ schema = { | ||
}; | ||
assert.throws(function() { | ||
parseCommands(schema, []); | ||
}, /ValidationError/); | ||
assert.strictEqual(tv4.validateResult(schema, COMMAND_JSON_SCHEMA).valid, false); | ||
@@ -154,5 +152,3 @@ schema = { | ||
}; | ||
assert.throws(function() { | ||
parseCommands(schema, []); | ||
}, /ValidationError/); | ||
assert.strictEqual(tv4.validateResult(schema, COMMAND_JSON_SCHEMA).valid, false); | ||
}); | ||
@@ -159,0 +155,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
12755
0
153
3
278