generate_shell_completion

Function generate_shell_completion 

Source
pub fn generate_shell_completion(result: &ProbeResult, shell: Shell) -> String
Expand description

Generate shell completion script for a command.

This generates a complete completion script that can be sourced to provide tab completion for the probed command.

ยงExamples

use help_probe::{completion::{generate_shell_completion, Shell}, model::ProbeResult};

let result = ProbeResult {
    command: "mytool".to_string(),
    args: vec![],
    exit_code: Some(0),
    timed_out: false,
    help_flag_detected: true,
    usage_blocks: vec![],
    options: vec![],
    subcommands: vec![],
    arguments: vec![],
    examples: vec![],
    environment_variables: vec![],
    validation_rules: vec![],
    raw_stdout: String::new(),
    raw_stderr: String::new(),
};

let bash_completion = generate_shell_completion(&result, Shell::Bash);
assert!(bash_completion.contains("mytool"));
assert!(bash_completion.contains("complete -F"));