use anyhow::Result;
use clap::{CommandFactory, Parser};
use clap_complete::{Shell, generate};
use std::io;
#[derive(Parser, Debug, Clone)]
#[command(name = "completions", about = "Generate shell completions")]
pub struct CompletionsCommand {
#[arg(value_enum)]
pub shell: Shell,
}
pub fn handle_completions<C: CommandFactory>(cmd: CompletionsCommand) -> Result<()> {
let mut command = C::command();
let name = command.get_name().to_string();
generate(cmd.shell, &mut command, name, &mut io::stdout());
Ok(())
}
impl crate::commands::executable::ExecutableCommand for CompletionsCommand {
fn execute(&self, _ctx: &crate::config::CliConfig) -> anyhow::Result<()> {
handle_completions::<crate::cli::AuthsCli>(self.clone())
}
}