diff --git a/lib/InteractiveOptions.ts b/lib/InteractiveOptions.ts index bd05d37..239d88f 100644 --- a/lib/InteractiveOptions.ts +++ b/lib/InteractiveOptions.ts @@ -4,7 +4,7 @@ /* eslint-disable no-process-env */ import { Persistent } from '@scode/modelling'; import fs from 'fs-extra'; -import yargs from 'yargs'; +import yargs, { Options } from 'yargs'; import { Confirm, Input } from 'enquirer'; enum OptionType { @@ -68,7 +68,7 @@ export class InteractiveOptions extends Persistent { ].includes (typeof value)) return; - const as_num = parseInt (value); + const as_num = parseInt (String (value)); const is_num = !isNaN (as_num); if (is_num) { opt.value = as_num; @@ -87,7 +87,8 @@ export class InteractiveOptions extends Persistent { const is_bool = [ 0, 1 - ].includes (value) || (/^(?:true|false)$/ui).test (value); + ].includes (parseInt (String (value))) + || (/^(?:true|false)$/ui).test (value as string); if (is_bool) { const as_bool = value === 1 || (/true/ui).test (value as string); opt.value = as_bool; @@ -127,7 +128,7 @@ export class InteractiveOptions extends Persistent { } private async get_args_options (): Promise { - const yargs_config = { + const yargs_config: Record = { quiet: { alias: 'q', default: false, @@ -143,7 +144,8 @@ export class InteractiveOptions extends Persistent { describe: opt.description }; } - const argv = yargs.options (yargs_config); + const argv = yargs.options (yargs_config) + .parse (); await Promise.all (this.options.map ((opt) => { if (typeof argv[opt.name] !== 'undefined') return this.assign_arg (opt, argv[opt.name]);