usage/complete/
mod.rs

1use crate::error::UsageErr;
2use crate::Spec;
3
4mod bash;
5mod fish;
6mod powershell;
7mod zsh;
8
9pub struct CompleteOptions {
10    pub usage_bin: String,
11    pub shell: String,
12    pub bin: String,
13    pub cache_key: Option<String>,
14    pub spec: Option<Spec>,
15    pub usage_cmd: Option<String>,
16    pub include_bash_completion_lib: bool,
17    pub source_file: Option<String>,
18}
19
20pub fn complete(options: &CompleteOptions) -> Result<String, UsageErr> {
21    match options.shell.as_str() {
22        "bash" => Ok(bash::complete_bash(options)),
23        "fish" => Ok(fish::complete_fish(options)),
24        "powershell" => Ok(powershell::complete_powershell(options)),
25        "zsh" => Ok(zsh::complete_zsh(options)),
26        _ => Err(UsageErr::UnsupportedShell(options.shell.clone())),
27    }
28}