/** * Commander Adapter - Commander.js implementation of the CLI framework adapter * * This is a concrete implementation of CommandAdapter using the Commander.js library. * The interfaces are defined separately to allow for other implementations (Yargs, Caporal, etc.) * * Benefits: * - Implements library-agnostic CommandAdapter interface * - Can be swapped with other implementations without changing consumers * - Provides compatibility methods for edge cases */ import { Command as CommanderCommand, Option as CommanderOption } from 'commander'; import type { CommandAdapter, OptionAdapter } from './command-adapter.interface.js'; /** * Commander-specific Command Adapter interface (for edge cases requiring direct access) * This interface is defined in the implementation file to keep the base interface library-agnostic */ export interface CommanderCommandContract extends CommandAdapter { /** * Get underlying commander instance (for compatibility) * @deprecated Use CommandAdapter interface methods when possible */ getUnderlyingCommand(): CommanderCommand; } /** * Commander-specific Option Adapter interface (for edge cases requiring direct access) * This interface is defined in the implementation file to keep the base interface library-agnostic */ export interface CommanderOptionContract extends OptionAdapter { /** * Get underlying option instance (for compatibility) * @deprecated Use OptionAdapter interface methods when possible */ getUnderlyingOption(): CommanderOption; } /** * Commander Command Adapter Implementation * * Concrete implementation of CommandAdapter using Commander.js */ export declare class CommanderCommandAdapter implements CommanderCommandContract { private cmd; constructor(nameAndArgs?: string); action(fn: (...args: Array>) => Promise | void): CommandAdapter; addOption(option: OptionAdapter): CommandAdapter; alias(aliasName: string): CommandAdapter; allowUnknownOption(arg?: boolean): CommandAdapter; argument(name: string, description?: string, fn?: (value: string, previous: T) => T, defaultValue?: T): CommandAdapter; command(nameAndArgs: string, opts?: { hidden?: boolean; isDefault?: boolean; }): CommandAdapter; description(str: string): CommandAdapter; getUnderlyingCommand(): CommanderCommand; hook(event: 'postAction' | 'preAction', fn: () => Promise | void): CommandAdapter; name(str: string): CommandAdapter; option(flags: string, description?: string, fn?: ((value: string, previous: T) => T) | T, defaultValue?: T): CommandAdapter; opts = Record>(): T; parse(argv?: readonly string[], options?: { from: 'node' | 'user'; }): CommandAdapter; parseAsync(argv?: readonly string[], options?: { from: 'node' | 'user'; }): Promise; version(str: string, flags?: string, description?: string): CommandAdapter; /** * Internal method to wrap an existing commander instance */ private withUnderlyingCommand; } /** * Commander Option Adapter Implementation * * Concrete implementation of OptionAdapter using Commander.js */ export declare class CommanderOptionAdapter implements CommanderOptionContract { private opt; constructor(flags: string, description?: string); argParser(fn: (value: string, previous: T) => T): OptionAdapter; choices(values: readonly string[]): OptionAdapter; default(value: unknown, description?: string): OptionAdapter; getUnderlyingOption(): CommanderOption; } /** * Factory function to create a new Command adapter */ export declare function createCommand(nameAndArgs?: string): CommandAdapter; /** * Factory function to create a new Option adapter */ export declare function createOption(flags: string, description?: string): OptionAdapter; export type { Command } from 'commander'; //# sourceMappingURL=commander-adapter.d.ts.map