import * as _alepha_core1 from "alepha";
import * as _alepha_core0 from "alepha";
import { Alepha, AlephaError, Async, Descriptor, KIND, Logger, Static, TObject, TSchema } from "alepha";
import * as fs from "node:fs/promises";
import { glob } from "node:fs/promises";
import * as _sinclair_typebox0 from "@sinclair/typebox";

//#region src/helpers/Runner.d.ts
type Task = {
  name: string;
  handler: () => any;
};
interface Timer {
  name: string;
  duration: string;
}
interface RunOptions {
  /**
   * Rename the command for logging purposes.
   */
  alias?: string;
  /**
   * If true, the command will not be logged.
   */
  silent?: boolean;
}
interface RunnerMethod {
  (cmd: string | Array<string | Task>, fn?: () => any, options?: RunOptions): Promise<string>;
  rm: (glob: string | string[], options?: RunOptions) => Promise<string>;
  cp: (source: string, dest: string, options?: RunOptions) => Promise<string>;
}
declare class Runner {
  protected readonly log: Logger;
  protected readonly timers: Timer[];
  protected readonly startTime: number;
  readonly run: RunnerMethod;
  constructor(log: Logger);
  protected createRunMethod(): RunnerMethod;
  protected exec(cmd: string): Promise<string>;
  /**
   * Executes one or more tasks.
   *
   * @param task - A single task or an array of tasks to run in parallel.
   */
  protected execute(task: Task | Task[]): Promise<string>;
  /**
   * Prints a summary of all executed tasks and their durations.
   */
  summary(): void;
  protected executeTask(task: Task): Promise<string>;
  protected renderTable(data: string[][]): void;
}
//#endregion
//#region src/descriptors/$command.d.ts
/**
 * Declares a CLI command.
 *
 * This descriptor allows you to define a command, its flags, and its handler
 * within your Alepha application structure.
 */
declare const $command: {
  <T extends TObject>(options: CommandDescriptorOptions<T>): CommandDescriptor<T>;
  [KIND]: typeof CommandDescriptor;
};
interface CommandDescriptorOptions<T extends TObject> {
  /**
   * The handler function to execute when the command is matched.
   */
  handler: (args: CommandHandlerArgs<T>) => Async<void>;
  /**
   * The name of the command. If omitted, the property key is used.
   *
   * An empty string "" denotes the root command.
   */
  name?: string;
  /**
   * A short description of the command, shown in the help message.
   */
  description?: string;
  /**
   * An array of alternative names for the command.
   */
  aliases?: string[];
  /**
   * A TypeBox object schema defining the flags for the command.
   */
  flags?: T;
  /**
   * If false, skip summary message at the end of the command execution.
   */
  summary?: boolean;
}
declare class CommandDescriptor<T extends TObject = TObject> extends Descriptor<CommandDescriptorOptions<T>> {
  readonly flags: TObject<{}>;
  readonly aliases: string[];
  get name(): string;
}
interface CommandHandlerArgs<T extends TObject> {
  flags: Static<T>;
  run: RunnerMethod;
  glob: typeof glob;
  fs: typeof fs;
}
//# sourceMappingURL=$command.d.ts.map
//#endregion
//#region src/errors/CommandError.d.ts
declare class CommandError extends AlephaError {
  readonly name = "CommandError";
}
//# sourceMappingURL=CommandError.d.ts.map
//#endregion
//#region src/providers/CliProvider.d.ts
declare const envSchema: TObject<{
  CLI_NAME: _alepha_core1.TString;
  CLI_DESCRIPTION: _alepha_core1.TString;
}>;
declare module "alepha" {
  interface Env extends Partial<Static<typeof envSchema>> {}
}
declare class CliProvider {
  protected readonly env: Static<typeof envSchema>;
  protected readonly alepha: Alepha;
  protected readonly log: Logger;
  options: {
    name: string;
    description: string;
    argv: string[];
  };
  protected readonly globalFlags: {
    help: {
      aliases: string[];
      description: string;
      schema: _sinclair_typebox0.TBoolean;
    };
  };
  protected readonly onReady: _alepha_core1.HookDescriptor<"ready">;
  get commands(): CommandDescriptor<any>[];
  private findCommand;
  protected parseCommandFlags(argv: string[], schema: TObject): Record<string, any>;
  protected parseFlags(argv: string[], flagDefs: {
    key: string;
    aliases: string[];
    schema: TSchema;
  }[]): Record<string, any>;
  printHelp(command?: CommandDescriptor<any>): void;
  private getMaxCmdLength;
  private getMaxFlagLength;
}
//#endregion
//#region src/index.d.ts
/**
 * This module provides a powerful way to build command-line interfaces
 * directly within your Alepha application, using declarative descriptors.
 *
 * It allows you to define commands using the `$command` descriptor.
 *
 * @see {@link $command}
 * @module alepha.command
 */
declare const AlephaCommand: _alepha_core0.Service<_alepha_core0.Module>;
declare module "@sinclair/typebox" {
  interface StringOptions {
    /**
     * Additional aliases for the flags.
     *
     * @module alepha.command
     */
    aliases?: string[];
  }
}
//# sourceMappingURL=index.d.ts.map

//#endregion
export { $command, AlephaCommand, CliProvider, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, RunOptions, Runner, RunnerMethod, Task };
//# sourceMappingURL=index.d.ts.map