/** * Wush environment manager * Manages environment variables, aliases etc. */ export class Environment { private variables: Record = {} private aliases: Record = {} SetVariable(name: string, value: any | null): void { if (value === null) { // remove the variable if value is null delete this.variables[name] } else this.variables[name] = String(value) } GetVariable(name: string): string | null { return this.variables[name] ?? null } SetAlias(name: string, value: string | null): void { if (value === null) { // remove the alias if value is null delete this.aliases[name] } else this.aliases[name] = value } GetAlias(name: string): string | null { return this.aliases[name] ?? null } GetAliasesByValue(value: string): string[] | null { const keys: string[] = [] for (const key in this.aliases) if (this.aliases[key] === value) keys.push(key) return keys.length === 0 ? null : keys } }