import { CompletionOptions } from "./shells/shared.mjs"; import { generateBashCompletion } from "./shells/bash.mjs"; import { generateFishCompletion } from "./shells/fish.mjs"; import { generatePowerShellCompletion } from "./shells/powershell.mjs"; import { generateZshCompletion } from "./shells/zsh.mjs"; import { CLISchema } from "../cli/index.mjs"; //#region src/core/completion/index.d.ts /** * Supported shell targets for completion script generation. * * `bash`, `zsh`, `fish`, and `powershell` are implemented today. */ type Shell = 'bash' | 'zsh' | 'fish' | 'powershell'; /** * Implemented shell values as a frozen readonly non-empty tuple. * * Use this tuple for user-facing validation and shell selection UIs. * It intentionally matches the shipped {@link Shell} union exactly so docs, * help output, and completion generation advertise the same support surface. * * @see {@link Shell} for the union type matching these entries. */ declare const SHELLS: Readonly; /** * Normalize a raw shell token — a bare name (`zsh`), a `$SHELL` path * (`/bin/zsh`), or a Windows executable (`…\pwsh.exe`) — to a supported * {@link Shell}, or `undefined` when it does not map to one. * * Mirrors the matching used by the `completions` subcommand so the subcommand * and the eager `--completions ` flag accept exactly the same inputs. * * @param raw - User-supplied shell token or interpreter path. * @returns The resolved {@link Shell}, or `undefined` if unrecognized. */ declare function normalizeShell(raw: string): Shell | undefined; /** * Auto-detect the current shell from environment variables. * * Resolution order: * 1. `$SHELL` parsed as an interpreter path (`/bin/zsh` → `zsh`). It wins when * it names a shell we support — a pwsh session launched from bash inherits * `SHELL=/bin/bash`, and the login shell the user opted into should be * honored over the fallback. * 2. Otherwise, the presence of `$PSModulePath` signals PowerShell. PowerShell * never sets `$SHELL` on any platform but always exports `PSModulePath` for * module discovery, so it is the reliable pwsh signal. * * Returns `undefined` when no signal resolves, leaving the caller to ask the * user for an explicit shell. * * @param env - Environment record (e.g. `process.env` or an adapter's env). * @returns The detected {@link Shell}, or `undefined`. */ declare function detectShell(env: Readonly>): Shell | undefined; /** * Generate a completion script for the given shell. * * This is the primary completion entrypoint for most consumers. Pass a CLI * schema and target shell, then write the returned script to a file or source * it directly from the command line. * * @param schema - The CLI schema describing commands, flags, and args. * @param shell - Target shell. * @param options - Optional generator configuration such as function naming * and root default-command completion behavior. * @returns A complete shell completion script as a string. * * @example * ```ts * const script = generateCompletion(app.schema, 'bash'); * // e.g. source <(mycli completions bash) * ``` */ declare function generateCompletion(schema: CLISchema, shell: Shell, options?: CompletionOptions): string; //#endregion export { type CompletionOptions, SHELLS, type Shell, detectShell, generateBashCompletion, generateCompletion, generateFishCompletion, generatePowerShellCompletion, generateZshCompletion, normalizeShell };