Skip to main content

Module completion

Module completion 

Source
Expand description

Shell completion support for click-rs.

This module provides shell completion functionality for Bash, Zsh, and Fish shells. It generates completion scripts that can be sourced in each shell to provide tab completion for CLI applications built with click-rs.

§Reference

Based on Python Click’s shell_completion.py.

§Example

use click::completion::{get_completion_class, shell_complete};
use click::command::Command;

let cmd = Command::new("myapp").build();

// Generate completion script for bash
if let Some(completer) = get_completion_class("bash") {
    let script = completer.source_template();
    println!("{}", script.replace("%(prog_name)s", "myapp"));
}

Structs§

BashComplete
Bash shell completion implementation.
CompletionArgs
Arguments parsed from the shell completion environment.
CompletionOption
Configuration for the shell completion option.
FishComplete
Fish shell completion implementation.
ZshComplete
Zsh shell completion implementation.

Traits§

ShellComplete
Trait for shell-specific completion implementations.

Functions§

detect_shell
Detect the current shell from environment.
get_completion_class
Get a shell completion implementation by name.
get_completions
Get completions for a command.
list_shells
List all supported shell names.
make_completion_option
Add the shell completion option to a command.
shell_complete
Main shell completion entry point.