Skip to main content

entrenar/cli/commands/
completion.rs

1//! Completion command implementation
2
3use crate::cli::logging::log;
4use crate::cli::LogLevel;
5use crate::config::{Cli, CompletionArgs, ShellType};
6use clap::CommandFactory;
7use clap_complete::{generate, Shell};
8
9pub fn run_completion(args: CompletionArgs, level: LogLevel) -> Result<(), String> {
10    log(level, LogLevel::Verbose, &format!("Generating completions for: {}", args.shell));
11
12    let mut cmd = Cli::command();
13    let shell = match args.shell {
14        ShellType::Bash => Shell::Bash,
15        ShellType::Zsh => Shell::Zsh,
16        ShellType::Fish => Shell::Fish,
17        ShellType::PowerShell => Shell::PowerShell,
18    };
19
20    generate(shell, &mut cmd, "entrenar", &mut std::io::stdout());
21    Ok(())
22}