Skip to main content

ShellComplete

Trait ShellComplete 

Source
pub trait ShellComplete: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn source_template(&self) -> &str;
    fn get_completion_args(&self) -> CompletionArgs;
    fn format_completion(&self, item: &CompletionItem) -> String;

    // Provided method
    fn get_source(&self, prog_name: &str, complete_var: &str) -> String { ... }
}
Expand description

Trait for shell-specific completion implementations.

Each shell has different completion mechanisms and script formats. Implementations of this trait provide the necessary integration for each shell.

Required Methods§

Source

fn name(&self) -> &str

Returns the name of the shell (e.g., “bash”, “zsh”, “fish”).

Source

fn source_template(&self) -> &str

Returns the shell script template for enabling completions.

The template can contain placeholders:

  • %(prog_name)s - The program name
  • %(complete_func)s - The completion function name
  • %(complete_var)s - The completion environment variable
Source

fn get_completion_args(&self) -> CompletionArgs

Get completion arguments from the shell environment.

Parses the completion environment variables set by the shell’s completion system and returns the arguments to complete.

Source

fn format_completion(&self, item: &CompletionItem) -> String

Format a completion item for output to the shell.

Each shell expects completions in a different format.

Provided Methods§

Source

fn get_source(&self, prog_name: &str, complete_var: &str) -> String

Get the source script with placeholders replaced.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§