release_kit/commands/completions.rs
1//! `rk completions`: shell completion generation.
2
3use clap::CommandFactory;
4
5use crate::cli::Cli;
6use crate::cli::completions::CompletionsArgs;
7use crate::error::RkError;
8use crate::output::Output;
9
10/// Generate completions for the requested shell on stdout.
11///
12/// The script is generated into a buffer and emitted through the output
13/// boundary, so the one command whose result clap produces still follows
14/// the same stream and failure policy as every other.
15///
16/// # Errors
17///
18/// Never fails; the signature matches the dispatch table.
19pub fn run(args: &CompletionsArgs) -> Result<(), RkError> {
20 let mut script = Vec::new();
21 clap_complete::generate(args.shell, &mut Cli::command(), "rk", &mut script);
22 Output::human().result_bytes(&script);
23 Ok(())
24}