docker-pilot
Version:
A powerful, scalable Docker CLI library for managing containerized applications of any size
87 lines • 2.62 kB
TypeScript
/**
* Base Command class for Docker Pilot CLI
* Provides common functionality for all commands
*/
import { CommandResult, CommandOptions, CommandContext } from '../types';
import { Logger } from '../utils/Logger';
import { I18n } from '../utils/i18n';
export declare abstract class BaseCommand {
readonly name: string;
readonly description: string;
readonly usage: string;
protected logger: Logger;
protected context: CommandContext;
protected i18n: I18n;
constructor(name: string, description: string, usage: string, context: CommandContext);
/**
* Execute the command
*/
abstract execute(args: string[], options: CommandOptions): Promise<CommandResult>; /**
* Validate command arguments
*/
protected validateArgs(args: string[], expectedCount?: number): boolean;
/**
* Show command usage
*/
showUsage(): void;
/**
* Show help for the command
*/
showHelp(): void;
/**
* Show command examples
* Override this method in subclasses
*/
protected showExamples(): void; /**
* Check if Docker is available
*/
protected checkDockerAvailable(): Promise<boolean>;
/**
* Create successful command result
*/
protected createSuccessResult(output?: string, executionTime?: number): CommandResult;
/**
* Create error command result
*/
protected createErrorResult(error: string, exitCode?: number, executionTime?: number): CommandResult;
/**
* Measure execution time
*/
protected measureExecutionTime<T>(operation: () => Promise<T>): Promise<{
result: T;
executionTime: number;
}>; /**
* Parse command options from arguments
* Supports both long (--option) and short (-o) option formats
* Examples:
* --follow
* --tail=50
* --since 1h
* -f
*/
protected parseOptions(args: string[]): {
args: string[];
options: Record<string, any>;
};
/**
* Confirm destructive action
*/
protected confirmAction(message: string): Promise<boolean>;
/**
* Validate service name exists in configuration
*/
protected validateService(serviceName: string): boolean;
/**
* Get available services from configuration
*/
protected getAvailableServices(): string[];
/**
* Get the main compose file from context
*/
protected getComposeFile(): string | undefined;
/**
* Check if any services are configured
*/
protected hasConfiguredServices(): boolean;
}
//# sourceMappingURL=BaseCommand.d.ts.map