small improvement, changelog, start documentation for 2.0
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import { OptionSource } from '../Sources/OptionSource';
|
||||
import { Option, OptionValue } from '../Option';
|
||||
import { EnvSource } from '../Sources/EnvSource';
|
||||
import { ErrorCallback } from '../ErrorCallback';
|
||||
import { ArgSource } from '../Sources/ArgSource';
|
||||
import { ConfigSource } from '../Sources/ConfigSource';
|
||||
import { TypeValidation } from '../TypeValidation/TypeValidation';
|
||||
@ -12,26 +11,30 @@ export abstract class BaseOption<T> {
|
||||
private _config: Option;
|
||||
|
||||
public constructor (
|
||||
config: Option,
|
||||
error_callback?: ErrorCallback,
|
||||
exit_on_interrupt = true
|
||||
config: Option
|
||||
) {
|
||||
this._config = config;
|
||||
|
||||
const sources = config.sources || {};
|
||||
if (typeof sources.configs !== 'undefined')
|
||||
this.sources.push (new ConfigSource (sources.configs, error_callback));
|
||||
const exit_on_interrupt = config.exit_on_interrupt !== false;
|
||||
|
||||
if (typeof sources.configs !== 'undefined') {
|
||||
this.sources.push (new ConfigSource (
|
||||
sources.configs,
|
||||
config.error_callback
|
||||
));
|
||||
}
|
||||
|
||||
if (sources.env !== false)
|
||||
this.sources.push (new EnvSource (error_callback));
|
||||
this.sources.push (new EnvSource (config.error_callback));
|
||||
|
||||
if (sources.console !== false)
|
||||
this.sources.push (new ArgSource (error_callback));
|
||||
this.sources.push (new ArgSource (config.error_callback));
|
||||
|
||||
if (sources.interactive !== false) {
|
||||
this.sources.push (new InteractiveSource (
|
||||
exit_on_interrupt,
|
||||
error_callback
|
||||
config.error_callback
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user