UNPKG

cmpstr-cli

Version:

Simple CLI wrapper for the CmpStr package to normalize and compare strings directly via terminal

50 lines (49 loc) 1.85 kB
/** * @fileoverview * Configuration utilities for CmpStr CLI * * Handles loading, merging, and resolving configuration from * YAML/JSON files and CLI options. * * @author Paul Köhler (komed3) * @license MIT */ import type { Config } from './types.js'; import { type Command } from 'commander'; /** * Loads a configuration file (YAML, YML, or JSON). * Falls back to the default config if no path is provided. * * @async * @param {string} [cfgPath] - Path to the config file. * @returns {Promise<Partial<Config>>} The loaded configuration object. * @throws {Error} If loading or parsing fails. */ export declare function loadCfg(cfgPath?: string): Promise<Partial<Config>>; /** * Deeply merges two configuration objects. * * @param {Partial<Config>} t - The target config object. * @param {Partial<Config>} o - The source config object to merge in. * @returns {Partial<Config>} The merged config object. */ export declare function mergeCfg(t?: Partial<Config>, o?: Partial<Config>): Partial<Config>; /** * Loads and merges configuration from file and CLI options. * * @async * @param {Partial<Config>} [cfg] - The base config object (e.g., from CLI). * @param {string} [cfgPath] - Path to the config file. * @returns {Promise<Partial<Config>>} The resolved configuration object. */ export declare function resolveCfg(cfg?: Partial<Config>, cfgPath?: string): Promise<Partial<Config>>; /** * Resolves the effective configuration for a command. * Merges global options, command options, and config file. * * @async * @param {Command} cmd - The Commander command instance. * @param {Record<string, any>} [opt] - Additional options to merge. * @returns {Promise<Partial<Config>>} The resolved configuration object. */ export declare function cfg(cmd: Command, opt?: Record<string, any>): Promise<Partial<Config>>;