fix boolean defaults

This commit is contained in:
Timo Hocker 2020-06-05 13:22:54 +02:00
parent cad6e5b738
commit 229b916cd5
2 changed files with 10 additions and 4 deletions

View File

@ -96,9 +96,13 @@ export class InteractiveOptions extends Persistent {
// eslint-disable-next-line no-await-in-loop
await src.parse (this.options);
}
for (const opt of this.options)
for (const opt of this.options) {
if (!opt.filled) {
opt.value = opt.default;
opt.filled = true;
}
this.set (opt.name, opt.value);
}
return this.to_object ();
}
}

View File

@ -28,10 +28,12 @@ export class ArgSource extends OptionSource {
}
};
for (const opt of options) {
const type = opt.type_validation.persistent_type;
yargs_config[opt.name] = {
alias: opt.alias,
default: opt.default,
type: opt.type_validation.persistent_type,
// eslint-disable-next-line no-undefined
default: type === 'boolean' ? undefined : opt.default,
type,
describe: opt.description
};
}