use crate::Wof;
use clap::{CommandFactory, Parser};
use clap_complete::{generate, Shell};
#[derive(Debug, Parser)]
pub enum Completion {
#[command(name = "bash")]
Bash,
#[command(name = "fish")]
Fish,
#[command(name = "zsh")]
Zsh,
#[command(name = "elvish")]
Elvish,
}
impl Completion {
pub fn exec(&self) {
let shell = match self {
Completion::Bash => Shell::Bash,
Completion::Fish => Shell::Fish,
Completion::Zsh => Shell::Zsh,
Completion::Elvish => Shell::Elvish,
};
let mut cli = Wof::command();
let bin_name = cli.get_name().to_string();
generate(shell, &mut cli, &bin_name, &mut std::io::stdout());
}
}