//! `cordance completions` — shell completion scripts. LANE-V1-COMPLETIONS.

use anyhow::Result;
use clap_complete::{generate, Shell};
use std::io;
use std::str::FromStr;

pub fn run(shell: &str, mut app: clap::Command) -> Result<()> {
    let shell = Shell::from_str(shell).map_err(|_| {
        anyhow::anyhow!("Unknown shell: '{shell}'. Try: bash, zsh, fish, powershell")
    })?;
    generate(shell, &mut app, "cordance", &mut io::stdout());
    Ok(())
}
