use anyhow::{Result, anyhow};
use clap::CommandFactory;
use clap_complete::{Shell, generate};
use crate::cli::Cli;
pub fn cmd_completion(_cli: &Cli, shell: String) -> Result<()> {
let mut cmd = Cli::command();
match shell.as_str() {
"bash" => {
generate(Shell::Bash, &mut cmd, "heddle", &mut std::io::stdout());
}
"zsh" => {
generate(Shell::Zsh, &mut cmd, "heddle", &mut std::io::stdout());
}
"fish" => {
generate(Shell::Fish, &mut cmd, "heddle", &mut std::io::stdout());
}
_ => {
return Err(anyhow!(
"Unsupported shell: {}. Supported shells: bash, zsh, fish",
shell
));
}
}
Ok(())
}