Skip to content
Snippets Groups Projects
Commit 95e2b93d authored by Alvaro Cabrera Durán's avatar Alvaro Cabrera Durán
Browse files

Setup argv for CLI

parent 016f76b1
No related branches found
No related tags found
No related merge requests found
...@@ -6,14 +6,48 @@ const jsf = require('../dist/main.umd.js'); ...@@ -6,14 +6,48 @@ const jsf = require('../dist/main.umd.js');
const sample = process.argv.slice(2)[0]; const sample = process.argv.slice(2)[0];
// FIXME: setup argv.... // FIXME: validate types on given input....
const argv = require('wargs')(process.argv.slice(2), { const argv = require('wargs')(process.argv.slice(2), {
boolean: 'O', boolean: 'DXMTFOxedrJUSE',
alias: { alias: {
'always-fake-optionals': 'O', D: 'defaultInvalidTypeProduct',
X: 'defaultRandExpMax',
p: 'ignoreProperties',
M: 'ignoreMissingRefs',
T: 'failOnInvalidTypes',
F: 'failOnInvalidFormat',
O: 'alwaysFakeOptionals',
o: 'optionalsProbability',
x: 'fixedProbabilities',
e: 'useExamplesValue',
d: 'useDefaultValue',
R: 'requiredOnly',
r: 'random',
i: 'minItems',
I: 'maxItems',
l: 'minLength',
L: 'maxLength',
J: 'resolveJsonPath',
U: 'reuseProperties',
S: 'fillProperties',
E: 'replaceEmptyByRandomValue',
}, },
}); });
if (typeof argv.flags.random === 'string') {
argv.flags.random = () => parseFloat(argv.flags.random);
}
if (typeof argv.flags.ignoreProperties === 'string') {
argv.flags.ignoreProperties = [argv.flags.ignoreProperties];
}
jsf.option(argv.flags);
const { inspect } = require('util'); const { inspect } = require('util');
const { Transform } = require('stream'); const { Transform } = require('stream');
const { readFileSync } = require('fs'); const { readFileSync } = require('fs');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment