UNPKG

@auttam/easycli

Version:

A quick and easy way of creating cli for your npm package.

34 lines (33 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Config = void 0; const config_error_1 = require("../errors/config-error"); const reflection_1 = require("../utility/reflection"); const string_1 = require("../utility/string"); class Config { constructor(config) { this.name = ''; this.help = ''; this.propName = ''; if (!config.name) throw new config_error_1.ConfigurationError('Option configuration must have name', config); this.name = config.name; this.help = config.help || ''; this.propName = config.propName || string_1.camelCase(this.name); } merge(config, options) { if (!config) return; var name = this.name; reflection_1.mergeTypeSafe(this, config, options); this.name = name; } toConfig() { return { name: this.name, help: this.help, propName: this.propName }; } } exports.Config = Config;