use anyhow::Result;
use clap_complete::Shell;
pub fn cmd_completion(shell: &str) -> Result<()> {
let _ = shell.parse::<Shell>().map_err(|_| {
anyhow::anyhow!("Invalid shell: {shell}. Supported shells: bash, zsh, fish")
})?;
let instructions = match shell {
"bash" => {
r"# ofsht shell completion setup for Bash
# Add this to your ~/.bashrc:
source <(COMPLETE=bash ofsht)
"
}
"zsh" => {
r"# ofsht shell completion setup for Zsh
# Add this to your ~/.zshrc:
source <(COMPLETE=zsh ofsht)
"
}
"fish" => {
r"# ofsht shell completion setup for Fish
# Add this to your ~/.config/fish/config.fish:
source (COMPLETE=fish ofsht | psub)
"
}
_ => {
anyhow::bail!("Unsupported shell: {shell}");
}
};
print!("{instructions}");
Ok(())
}