//! Handler for `mcptest completions`.

use std::io;

use anyhow::Result;
use clap::CommandFactory;
use clap_complete::Shell;

use crate::cli::Cli;

/// Emit a shell completion script for `shell` to stdout.
///
/// Lives in this module rather than its own file because it is a single call
/// into `clap_complete` and splitting it would obscure intent.
pub(crate) fn run_completions(shell: Shell) -> Result<i32> {
    let mut cmd = Cli::command();
    clap_complete::generate(shell, &mut cmd, "mcptest", &mut io::stdout());
    Ok(0)
}
