Comparing version 0.1.2 to 0.1.3
@@ -6,3 +6,4 @@ #!/usr/bin/env node | ||
var argv = _interopDefault(require('yargs')); | ||
var argv = require('yargs'); | ||
var argv__default = _interopDefault(argv); | ||
var path = _interopDefault(require('path')); | ||
@@ -15,3 +16,3 @@ var askJSON = _interopDefault(require('./index.js')); | ||
var name = "ask-json"; | ||
var version = "0.1.2"; | ||
var version = "0.1.3"; | ||
@@ -52,8 +53,12 @@ var ensureFile = (filePath) => { | ||
const config = {}; | ||
if (args.retries) config.maxRetries = args.retries; | ||
if (args.add) config.askToAddItems = args.add; | ||
if (!args.file) { | ||
VALID_DATA = await askJSON(SCHEMA, {}); | ||
VALID_DATA = await askJSON(SCHEMA, {}, config); | ||
} else { | ||
ensureFile(args.file); | ||
const RAW_DATA = readJSON(args.RAW_DATA); | ||
VALID_DATA = await askJSON(SCHEMA, RAW_DATA); | ||
VALID_DATA = await askJSON(SCHEMA, RAW_DATA, config); | ||
} | ||
@@ -73,3 +78,3 @@ if (args.output) { | ||
argv // eslint-disable-line no-unused-expressions | ||
argv__default // eslint-disable-line no-unused-expressions | ||
.command('$0 <schema>', | ||
@@ -95,6 +100,17 @@ 'Ask users for data based on JSON schema', (yargs) => { | ||
}, | ||
add: { | ||
alias: 'a', | ||
describe: 'Ask to add items to arrays.', | ||
type: argv.boolean, | ||
default: false, | ||
}, | ||
retries: { | ||
alias: 'r', | ||
describe: 'Maximum number of times to retry the same validation error.', | ||
type: 'number', | ||
coerce: (num) => parseInt(num), | ||
}, | ||
}) | ||
.help() | ||
.version(); | ||
}, run) | ||
.argv; |
{ | ||
"name": "ask-json", | ||
"description": "Easy interactive prompts to create and validate data using JSON schema", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Jon McClure <jon.r.mcclure@gmail.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/reuters-graphics/ask-json", |
29665
625