From b5af594fec7da72b15c9a202c641af0494db6355 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 21 Feb 2026 23:50:43 +0900 Subject: feat(completion): add shell completion generation via clap_complete Add a `completion` subcommand that generates shell completion scripts for Bash, Zsh, Fish, Elvish, and PowerShell using the clap_complete crate. Co-Authored-By: Claude Opus 4.6 --- crates/mozart/src/commands/completion.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 crates/mozart/src/commands/completion.rs (limited to 'crates/mozart/src/commands/completion.rs') diff --git a/crates/mozart/src/commands/completion.rs b/crates/mozart/src/commands/completion.rs new file mode 100644 index 0000000..406749c --- /dev/null +++ b/crates/mozart/src/commands/completion.rs @@ -0,0 +1,20 @@ +use clap::Args; +use clap::CommandFactory; +use clap_complete::aot::Shell; + +#[derive(Args)] +pub struct CompletionArgs { + /// The shell to generate completions for + #[arg(value_enum)] + pub shell: Shell, +} + +pub fn execute( + args: &CompletionArgs, + _cli: &super::Cli, + _console: &crate::console::Console, +) -> anyhow::Result<()> { + let mut cmd = super::Cli::command(); + clap_complete::aot::generate(args.shell, &mut cmd, "mozart", &mut std::io::stdout()); + Ok(()) +} -- cgit v1.3.1