usage/complete/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::Spec;

mod bash;
mod fish;
mod zsh;

pub struct CompleteOptions {
    pub shell: String,
    pub bin: String,
    pub cache_key: Option<String>,
    pub spec: Option<Spec>,
    pub usage_cmd: Option<String>,
}

pub fn complete(options: &CompleteOptions) -> String {
    match options.shell.as_str() {
        "bash" => bash::complete_bash(options),
        "fish" => fish::complete_fish(options),
        "zsh" => zsh::complete_zsh(options),
        _ => unimplemented!("unsupported shell: {}", options.shell),
    }
}