0.8.1 • Published 3 years ago
@cling/parser v0.8.1
@cling/parser
Write a declarative & serializeable schema inspired by JSON schema describing your CLI application & use it to parse/validate the arguments.
Usage
Supply a schema to @cling/parser
and it will parse the CLI arguments according to the schema.
import clingParser from '@cling/parser'
const navalFate = {
"name": "ship",
"description": "Naval Fate",
"commands": {
"new": {
"description": "Create a new ship",
"arguments": {
"name": {
"$ref": "#/definitions/name"
},
}
},
"move": {
"description": "Move a ship",
"arguments": {
"name": {
"$ref": "#/definitions/name"
},
"x": {
"$ref": "#/definitions/x"
},
"y": {
"$ref": "#/definitions/y"
},
"speed": {
"type": "number",
"description": "Speed in knots"
}
},
"required": ["name", "x", "y"]
},
"shoot": {
"description": "Shoot with a ship",
"arguments": {
"x": {
"$ref": "#/definitions/x"
},
"y": {
"$ref": "#/definitions/y"
}
}
}
},
"definitions": {
"name": {
"type": "string",
"description": "Ship name"
},
"x": {
"type": "integer"
},
"y": {
"type": "integer"
}
},
"options": {
"help": {
"type": "boolean",
"alias": "h"
}
}
}
const parsedArguments = clingParser(navalFate)
if(parsedArguments.new) {
console.log(`Creating ship ${parsedArguments.new.arguments.name}`)
}
0.8.1
3 years ago
0.8.0
3 years ago
0.7.3
3 years ago
0.7.2
3 years ago
0.7.1
3 years ago
0.7.0
3 years ago
0.6.7
3 years ago
0.6.6
3 years ago
0.6.9
3 years ago
0.6.8
3 years ago
0.6.3
3 years ago
0.6.5
3 years ago
0.6.4
3 years ago
0.6.2
3 years ago
0.5.0
3 years ago
0.6.1
3 years ago
0.5.2
3 years ago
0.6.0
3 years ago
0.5.1
3 years ago
0.4.6
3 years ago
0.4.5
3 years ago
0.4.4
3 years ago
0.4.1
3 years ago
0.4.2
3 years ago
0.4.0
3 years ago
0.3.0
3 years ago
0.2.3
3 years ago
0.2.2
3 years ago
0.2.1
3 years ago
0.2.0
3 years ago
0.1.0
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago