complete remodelling
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { TypeValidation } from '../TypeValidation/TypeValidation';
|
||||
import { BaseOption } from './BaseOption';
|
||||
|
||||
export class ArrayOption extends BaseOption {
|
||||
export class ArrayOption extends BaseOption<(string|number|boolean)[]> {
|
||||
protected get validation ():TypeValidation {
|
||||
return new TypeValidation ('array');
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import { ErrorCallback } from '../ErrorCallback';
|
||||
import { ArgSource } from '../Sources/ArgSource';
|
||||
import { ConfigSource } from '../Sources/ConfigSource';
|
||||
import { TypeValidation } from '../TypeValidation/TypeValidation';
|
||||
import { InteractiveSource } from '../Sources/InteractiveSource';
|
||||
|
||||
export abstract class BaseOption<T> {
|
||||
protected readonly sources: OptionSource[] = [];
|
||||
@ -44,8 +45,8 @@ export abstract class BaseOption<T> {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await source.parse (this._config, val);
|
||||
|
||||
if (!val.assinged)
|
||||
return this._config.default;
|
||||
return val.value;
|
||||
if (!val.filled)
|
||||
return this._config.default as T;
|
||||
return val.value as T;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { TypeValidation } from '../TypeValidation/TypeValidation';
|
||||
import { BaseOption } from './BaseOption';
|
||||
|
||||
export class BooleanOption extends BaseOption {
|
||||
export class BooleanOption extends BaseOption<boolean> {
|
||||
protected get validation ():TypeValidation {
|
||||
return new TypeValidation ('boolean');
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { PathType } from '../TypeValidation/PathType';
|
||||
import { TypeValidation } from '../TypeValidation/TypeValidation';
|
||||
import { StringOption } from './StringOption';
|
||||
|
||||
export class FileOption extends StringOption {
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { PathType } from '../TypeValidation/PathType';
|
||||
import { TypeValidation } from '../TypeValidation/TypeValidation';
|
||||
import { StringOption } from './StringOption';
|
||||
|
||||
export class FolderOption extends StringOption {
|
||||
protected get validation ():TypeValidation {
|
||||
protected get validation (): TypeValidation {
|
||||
return new PathType ('folder');
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { TypeValidation } from '../TypeValidation/TypeValidation';
|
||||
import { BaseOption } from './BaseOption';
|
||||
|
||||
export class NumberOption extends BaseOption {
|
||||
export class NumberOption extends BaseOption<number> {
|
||||
protected get validation ():TypeValidation {
|
||||
return new TypeValidation ('number');
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { PathType } from '../TypeValidation/PathType';
|
||||
import { TypeValidation } from '../TypeValidation/TypeValidation';
|
||||
import { StringOption } from './StringOption';
|
||||
|
||||
export class PathOption extends StringOption {
|
||||
protected get validation ():TypeValidation {
|
||||
protected get validation (): TypeValidation {
|
||||
return new PathType ('path');
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
import { TypeValidation } from '../TypeValidation/TypeValidation';
|
||||
import { Option } from '../Option';
|
||||
import { StringOptionConfig } from '../SubConfigs';
|
||||
import { BaseOption } from './BaseOption';
|
||||
|
||||
interface StringOptionConfig extends Option {
|
||||
preset?: string[]
|
||||
}
|
||||
|
||||
export class StringOption extends BaseOption {
|
||||
export class StringOption extends BaseOption<string> {
|
||||
protected get validation ():TypeValidation {
|
||||
return new TypeValidation ('string');
|
||||
}
|
||||
|
Reference in New Issue
Block a user