export function requireValue(args: string[], index: number, flag: string): string { const value = args[index] if (!value || value.startsWith("--")) { throw new Error(`Missing value for ${flag}`) } return value } export function splitPaths(value: string): string[] { return value .split(",") .map((part) => part.trim()) .filter(Boolean) } export function dedupeNonEmpty(values: string[]): string[] { const seen = new Set() const output: string[] = [] for (const value of values) { const trimmed = value.trim() if (!trimmed || seen.has(trimmed)) continue seen.add(trimmed) output.push(trimmed) } return output } export function parsePositiveInteger(raw: string, flag: string): number { const value = Number(raw) if (!Number.isInteger(value) || value <= 0) { throw new Error(`${flag} must be a positive integer.`) } return value }