use clap_complete::{generate, Shell};
pub fn cmd_completions(shell: Shell) {
use clap::{Arg, ArgAction, Command};
let mut cmd = Command::new("wasm-slim")
.version(env!("CARGO_PKG_VERSION"))
.about("WASM bundle size optimizer")
.arg(
Arg::new("no-emoji")
.long("no-emoji")
.help("Disable emoji output")
.action(ArgAction::SetTrue)
.global(true),
)
.subcommand(Command::new("build").about("Build and optimize WASM binary"))
.subcommand(Command::new("analyze").about("Analyze WASM bundle or dependencies"))
.subcommand(Command::new("init").about("Initialize wasm-slim configuration"))
.subcommand(Command::new("compare").about("Compare two WASM builds"))
.subcommand(Command::new("completions").about("Generate shell completions"));
let bin_name = "wasm-slim".to_string();
generate(shell, &mut cmd, bin_name, &mut std::io::stdout());
}
#[cfg(test)]
mod tests {
use clap_complete::Shell;
#[test]
fn test_cmd_completions_bash_generates_output() {
let shells = [Shell::Bash, Shell::Zsh, Shell::Fish, Shell::PowerShell];
for shell in shells {
let _ = shell; }
}
#[test]
fn test_cmd_completions_all_shells_supported() {
let _bash = Shell::Bash;
let _zsh = Shell::Zsh;
let _fish = Shell::Fish;
let _powershell = Shell::PowerShell;
}
}