console-app/lib/Sources/OptionSource.ts

19 lines
401 B
TypeScript
Raw Normal View History

2020-05-09 21:30:37 +02:00
import { OptionProcess } from '../Option';
2020-05-09 19:51:43 +02:00
export abstract class OptionSource {
public abstract async parse(opt: OptionProcess[]): Promise<void>;
protected async assign_arg (
opt: OptionProcess,
value: unknown
): Promise<void> {
try {
opt.value = await opt.type_validation.to_type (value);
opt.filled = true;
}
catch (e) {
// could not assing
}
}
}