Completions.ts
Completions.ts overview
Section titled “Completions.ts overview”The Completions module turns a plain description of an Effect CLI command
tree into shell completion scripts for Bash, Zsh, and Fish. It is the
low-level script generation surface used by the unstable CLI package and by
the built-in completions global flag.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”constructors
Section titled “constructors”generate
Section titled “generate”Generates a shell completion script for a command descriptor.
When to use
Use when you need an installable completion script from an existing
CommandDescriptor.
Details
Dispatches by shell to Bash, Zsh, or Fish generation and returns a static
script string for executableName.
See
Shellfor supported shell namesCommandDescriptorfor the command shape used by completion generation
Signature
declare const generate: (executableName: string, shell: Shell, descriptor: CommandDescriptor) => stringSince v4.0.0
models
Section titled “models”ArgumentDescriptor (interface)
Section titled “ArgumentDescriptor (interface)”Describes a positional argument for completions.
Signature
export interface ArgumentDescriptor { readonly name: string readonly description: string | undefined readonly required: boolean readonly variadic: boolean readonly type: ArgumentType}Since v4.0.0
ArgumentType (type alias)
Section titled “ArgumentType (type alias)”Describes the supported argument value shapes.
Signature
type ArgumentType = | { readonly _tag: "String" } | { readonly _tag: "Integer" } | { readonly _tag: "Float" } | { readonly _tag: "Date" } | { readonly _tag: "Choice"; readonly values: ReadonlyArray<string> } | { readonly _tag: "Path"; readonly pathType: "file" | "directory" | "either" }Since v4.0.0
CommandDescriptor (interface)
Section titled “CommandDescriptor (interface)”Describes a command for completion script generation.
Signature
export interface CommandDescriptor { readonly name: string readonly description: string | undefined readonly flags: ReadonlyArray<FlagDescriptor> readonly arguments: ReadonlyArray<ArgumentDescriptor> readonly subcommands: ReadonlyArray<CommandDescriptor>}Since v4.0.0
FlagDescriptor (interface)
Section titled “FlagDescriptor (interface)”Describes a command flag for completions.
Signature
export interface FlagDescriptor { readonly name: string readonly aliases: ReadonlyArray<string> readonly description: string | undefined readonly type: FlagType}Since v4.0.0
FlagType (type alias)
Section titled “FlagType (type alias)”Describes the supported flag value shapes.
Signature
type FlagType = | { readonly _tag: "Boolean" } | { readonly _tag: "String" } | { readonly _tag: "Integer" } | { readonly _tag: "Float" } | { readonly _tag: "Date" } | { readonly _tag: "Choice"; readonly values: ReadonlyArray<string> } | { readonly _tag: "Path"; readonly pathType: "file" | "directory" | "either" }Since v4.0.0
Shell (type alias)
Section titled “Shell (type alias)”Shell type used to generate completion scripts.
Signature
type Shell = "bash" | "zsh" | "fish"Since v4.0.0