import { CrustPlugin as CrustPlugin7 } from "@crustjs/core"; import { CrustPlugin } from "@crustjs/core"; interface DidYouMeanPluginOptions { mode?: "error" | "help"; } declare function didYouMeanPlugin(options?: DidYouMeanPluginOptions): CrustPlugin; import { CrustPlugin as CrustPlugin2 } from "@crustjs/core"; /** The set of shells supported by the v1 completion plugin. */ type CompletionShell = "bash" | "zsh" | "fish"; /** Options for {@link completionPlugin}. */ interface CompletionPluginOptions { /** * Subcommand name. Defaults to `"completion"`. Override only if the * default conflicts with an existing user-defined command. */ command?: string; /** * Binary name embedded in generated scripts (the `complete -F` target, * the `#compdef` line, the `complete -c ` rules). Defaults to the * root command's `meta.name`. */ binName?: string; /** * Shells to emit when running ` completion --output-dir`. * Defaults to all three. The positional `` argument is always * the union of these values regardless of any narrower setting (we * intentionally keep the user-facing CLI predictable). */ shells?: readonly CompletionShell[]; /** * Free-form version string embedded in generated script headers. The * walker does not parse it — it flows through as text. Defaults to * `"0.0.0"`. Pass your `package.json` version when wiring the plugin. */ version?: string; } /** * Build a `CrustPlugin` that registers a `completion ` subcommand * which emits a tab-completion script for bash, zsh, or fish. * * **Strategy: pure-static.** The walk happens lazily inside `run()` (not * at `setup()` time) so plugin order is irrelevant — any subcommands or * inherited flags added by other plugins are visible by the time we * generate the script. The walker projects `rootCommand` to a small * `CompletionSpec`; per-shell renderers turn that into a self-contained * shell script with no runtime callbacks. * * **Print vs `--output-dir`.** * - With no `--output-dir`: print the script for the requested `` * to stdout (the install pattern is * `mycli completion bash > ~/.local/share/...`). * - With `--output-dir `: write **all** configured shells' files * into the directory using the canonical per-shell filename * (`` for bash, `_` for zsh, `.fish` for fish). This * is the artifact-generation path used by Homebrew, Nix, and similar * distribution channels — distributors run it once at packaging time * and the resulting files become drop-ins. */ declare function completionPlugin(options?: CompletionPluginOptions): CrustPlugin2; import { CommandNode, CrustPlugin as CrustPlugin3 } from "@crustjs/core"; declare function renderHelp(command: CommandNode, path?: string[]): string; declare function helpPlugin(): CrustPlugin3; import { CrustPlugin as CrustPlugin4 } from "@crustjs/core"; declare function noColorPlugin(): CrustPlugin4; import { CrustPlugin as CrustPlugin5 } from "@crustjs/core"; type UpdateNotifierPackageManager = "npm" | "pnpm" | "yarn" | "bun"; type UpdateNotifierInstallScope = "local" | "global"; interface UpdateNotifierState { lastCheckedAt: number; latestVersion?: string; lastNotifiedVersion?: string; } interface UpdateNotifierCacheAdapter { read(): Promise; write(state: UpdateNotifierState): Promise; } /** * Cache configuration for the update notifier plugin. * * Wraps a {@link UpdateNotifierCacheAdapter} with cache-specific settings. */ interface UpdateNotifierCacheConfig { /** * Persistence adapter for reading and writing notifier state. */ adapter: UpdateNotifierCacheAdapter; /** * Minimum interval in milliseconds between network update checks. * * Cached results are reused until this interval elapses. * * @default 86_400_000 (24 hours) */ intervalMs?: number; } /** * Configuration options for the update notifier plugin. * * @example * ```ts * import { updateNotifierPlugin } from "@crustjs/plugins"; * * updateNotifierPlugin({ * packageName: "my-cli", * currentVersion: "1.2.3", * }); * ``` */ interface UpdateNotifierPluginOptions { /** * The current version of the CLI package. * * Typically sourced from `package.json`: * ```ts * import pkg from "../package.json"; * updateNotifierPlugin({ packageName: pkg.name, currentVersion: pkg.version }); * ``` */ currentVersion: string; /** * The npm package name to check for updates. */ packageName: string; /** * Network request timeout in milliseconds for the registry check. * * If the check does not complete within this duration, it is silently * aborted and treated as a soft failure. * * @default 5_000 (5 seconds) */ timeoutMs?: number; /** * Custom npm registry URL to query for the latest version. * * @default "https://registry.npmjs.org" */ registryUrl?: string; /** * Package manager used to generate the suggested upgrade command. * * Set to "auto" (default) to infer from the runtime environment. */ packageManager?: UpdateNotifierPackageManager | "auto"; /** * Install scope used to generate the suggested upgrade command. * * Set to "auto" (default) to infer whether the CLI is running from a * global install or a project-local dependency. */ installScope?: UpdateNotifierInstallScope | "auto"; /** * Override the upgrade command shown in the notice. * * Useful when users install the CLI globally or through channels other than * npm-style package managers (e.g. Homebrew, custom installers). */ updateCommand?: string | ((packageName: string, packageManager: UpdateNotifierPackageManager, installScope: UpdateNotifierInstallScope) => string); /** * Optional cache configuration for cross-run persistence. * * By default, no cross-run persistence is used and checks occur once * per process execution. * * @example * ```ts * cache: { * adapter: { * read: async () => ({ lastCheckedAt: 0 }), * write: async (state) => { * await store.write({ * lastCheckedAt: state.lastCheckedAt, * latestVersion: state.latestVersion, * lastNotifiedVersion: state.lastNotifiedVersion, * }); * }, * }, * intervalMs: 86_400_000, // 24 hours * } * ``` */ cache?: UpdateNotifierCacheConfig; } /** * Creates an update notifier plugin that performs background version checks * against the npm registry and displays a concise notice when a newer * version is available. * * **Behavior:** * - With `cache`, checks are reused up to `cache.intervalMs` (default 24h). * - Without `cache`, checks run once per process execution. * - The network check is non-blocking — it never delays command execution. * - All internal errors (network, cache, parsing) are silently swallowed. * - The update notice is emitted *after* the command handler completes. * - Duplicate notifications for the same version are suppressed. * * @param options - Plugin configuration. `currentVersion` and `packageName` are required. * @returns A {@link CrustPlugin} instance. * * @example * ```ts * import { Crust } from "@crustjs/core"; * import { updateNotifierPlugin } from "@crustjs/plugins"; * import pkg from "../package.json"; * * const app = new Crust("my-cli").meta({ description: "My awesome CLI" }) * .use(updateNotifierPlugin({ packageName: "my-cli", currentVersion: pkg.version })) * .run(() => { * console.log("Hello!"); * }); * * await app.execute(); * ``` */ declare function updateNotifierPlugin(options: UpdateNotifierPluginOptions): CrustPlugin5; import { CrustPlugin as CrustPlugin6 } from "@crustjs/core"; type VersionValue = string | (() => string); declare function versionPlugin(versionValue?: VersionValue): CrustPlugin6; /** * @deprecated Use `didYouMeanPlugin` instead. Will be removed in 1.0.0. * * Wraps `didYouMeanPlugin` and preserves the legacy `name: "autocomplete"` * field so existing consumers that key off `plugin.name` keep working until * the alias is removed in 1.0.0. */ declare const autoCompletePlugin: (options?: DidYouMeanPluginOptions) => CrustPlugin7; /** * @deprecated Use `DidYouMeanPluginOptions` instead. Will be removed in 1.0.0. */ type AutoCompletePluginOptions = DidYouMeanPluginOptions; export { versionPlugin, updateNotifierPlugin, renderHelp, noColorPlugin, helpPlugin, didYouMeanPlugin, completionPlugin, autoCompletePlugin, VersionValue, UpdateNotifierPluginOptions, UpdateNotifierPackageManager, UpdateNotifierInstallScope, UpdateNotifierCacheConfig, UpdateNotifierCacheAdapter, DidYouMeanPluginOptions, CompletionShell, CompletionPluginOptions, AutoCompletePluginOptions };