import { PadroneBarConfig, PadroneProgress, PadroneSpinnerConfig } from "../core/runtime.mjs"; import { WithInterceptor } from "../util/type-utils.mjs"; import { CommandTypesBase } from "../types/command.mjs"; import { PadroneProgressRenderer } from "./progress-renderer.mjs"; //#region src/extension/progress.d.ts /** A progress message value: a plain string, `null` to suppress, or an object with a message and custom indicator icon. */ type PadroneProgressMessage = string | null | { message?: string | null; indicator?: string; }; /** Per-phase message configuration for progress indicators. */ type PadroneProgressMessages = { /** Message shown during async validation. Defaults to `''` (spinner only). */validation?: string; /** Message shown while the command's action is running. */ progress?: string; /** Message shown when the command succeeds. `null` to suppress. Defaults to the `progress` message. */ success?: PadroneProgressMessage | ((result: TRes) => PadroneProgressMessage); /** Message shown when the command fails. `null` to suppress. Defaults to the error message. */ error?: PadroneProgressMessage | ((error: unknown) => PadroneProgressMessage); }; /** * Progress indicator configuration with messages, visual options, and renderer. */ type PadroneProgressConfig = { /** Per-phase messages. A string sets the `progress` message; an object configures individual phases. */message?: string | PadroneProgressMessages; /** Spinner configuration. Default `show` is `'auto'` (visible when bar is not shown). `true` forces spinner to always show (even alongside a bar). */ spinner?: PadroneSpinnerConfig; /** Enable a progress bar. `true` for defaults (`show: 'always'`), or a `PadroneBarConfig` object. `false` to disable entirely. When omitted, bar defaults to `show: 'auto'`. */ bar?: boolean | PadroneBarConfig; /** Show elapsed time since the indicator started. Can also be started on demand via `update({ time: true })`. */ time?: boolean; /** Show estimated time remaining based on progress rate. Requires numeric `update()` calls. */ eta?: boolean; /** * Custom renderer factory. Called to create the progress indicator. * Defaults to the built-in terminal renderer (`createTerminalProgress`). */ renderer?: PadroneProgressRenderer; /** Suppress all progress output. The `progress` interface is still provided on the context as a no-op. */ silent?: boolean; }; /** * Shared progress defaults that can be provided via context instead of repeating * at each call site. Per-instance message fields are excluded — those always come * from the constructor argument. * * Provide via context as `{ progressConfig: PadroneProgressDefaults }`. */ type PadroneProgressDefaults = Pick; /** Builder/program type after applying `padroneProgress()`. Adds `{ progress: PadroneProgress }` to the command context. */ type WithProgress = WithInterceptor; /** * Extension that adds an auto-managed progress indicator to the command pipeline. * * - `string` — a single message used for all states. * - `PadroneProgressConfig` — separate messages for validation, progress, success, and error. * * The indicator is automatically started before validation, updated at each phase transition, * and stopped on success (`.succeed()`) or failure (`.fail()`). * * Provides `{ progress: PadroneProgress }` on the command context. * Access it in action handlers as `ctx.context.progress`. * * Uses the built-in terminal renderer by default. Pass a custom `renderer` for non-terminal * environments (web UIs, testing, etc). * * Usage: * ```ts * createPadrone('my-cli') * .command('sync', (c) => * c.extend(padroneProgress('Syncing...')) * .action((_args, ctx) => { * ctx.context.progress.update('halfway'); * }) * ) * ``` */ declare function padroneProgress(config?: string | PadroneProgressConfig): (builder: T) => WithProgress; //#endregion export { PadroneProgressConfig, PadroneProgressDefaults, PadroneProgressMessage, PadroneProgressMessages, WithProgress, padroneProgress }; //# sourceMappingURL=progress.d.mts.map