UNPKG

sourcecontrol

Version:

A modern TypeScript CLI application for source control

46 lines 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigEntry = exports.ConfigLevel = void 0; var ConfigLevel; (function (ConfigLevel) { ConfigLevel["COMMAND_LINE"] = "command-line"; ConfigLevel["REPOSITORY"] = "repository"; ConfigLevel["USER"] = "user"; ConfigLevel["SYSTEM"] = "system"; ConfigLevel["BUILTIN"] = "builtin"; })(ConfigLevel || (exports.ConfigLevel = ConfigLevel = {})); class ConfigEntry { constructor(key, value, level, source, lineNumber) { this.key = key; this.value = value; this.level = level; this.source = source; this.lineNumber = lineNumber ?? 0; } asString() { return this.value; } asNumber() { const num = Number(this.value); if (isNaN(num)) { throw new Error(`Cannot convert "${this.value}" to number`); } return num; } asBoolean() { const lower = this.value.toLowerCase(); if (lower === 'true' || lower === 'yes' || lower === '1') return true; if (lower === 'false' || lower === 'no' || lower === '0') return false; throw new Error(`Cannot convert "${this.value}" to boolean`); } asList() { return this.value .split(',') .map((s) => s.trim()) .filter((s) => s.length > 0); } } exports.ConfigEntry = ConfigEntry; //# sourceMappingURL=config-level.js.map