feat: cli flags

This commit is contained in:
evilebottnawi 2020-03-10 14:58:01 +03:00 committed by Tobias Koppers
parent 59993a8855
commit f728b209b4
2 changed files with 1698 additions and 378 deletions

File diff suppressed because it is too large Load Diff

View File

@ -35,20 +35,30 @@ function getSchemaPart(path) {
function addFlag(schemaPath, schemaPart, multiple) {
const name = decamelize(schemaPath.replace(/\//g, "-"));
// TODO move it under property
const types = schemaPart.enum
? [...new Set(schemaPart.enum.map(item => typeof item))]
: Array.isArray(schemaPart.type)
? schemaPart.type
: [schemaPart.type];
if (flags[name]) {
flags[name].types = [...new Set(flags[name].types.concat(types))];
} else {
flags[name] = { types, description: schemaPart.description };
if (!flags[name]) {
flags[name] = {
types: [],
description: schemaPart.description
};
}
if (multiple) {
flags[name].multiple = true;
for (const type of types) {
const duplicateIndex = flags[name].types.findIndex(() => type === type);
if (duplicateIndex > -1) {
flags[name].types[duplicateIndex].multiple = true;
break;
}
flags[name].types.push({ type: type, multiple });
}
}