reactive_graph_client/shared/completions/
mod.rs1pub mod args;
2pub mod commands;
3#[cfg(target_os = "linux")]
4pub mod error;
5#[cfg(target_os = "linux")]
6pub mod install;
7
8pub mod print;
9
10use crate::shared::completions::args::ShellCompletionsArguments;
11use crate::shared::completions::commands::ShellCompletionsActionCommands;
12use crate::shared::completions::commands::ShellCompletionsCommands;
13use clap::CommandFactory;
14#[cfg(target_os = "linux")]
15pub use install::install_shell_completions;
16pub use print::print_shell_completions;
17use std::process::exit;
18
19pub fn handle_completions<T: CommandFactory>(args: &ShellCompletionsArguments) {
21 if let Some(commands) = &args.commands {
22 let mut cmd = T::command();
23 match commands {
24 ShellCompletionsCommands::ShellCompletions(args) => match &args.commands {
25 ShellCompletionsActionCommands::Print(args) => {
26 print_shell_completions(args.shell, &mut cmd);
27 exit(0);
28 }
29 #[cfg(target_os = "linux")]
30 ShellCompletionsActionCommands::Install(args) => {
31 if let Err(e) = install_shell_completions(args.shell, args.shell, &mut cmd) {
32 eprintln!("Failed to install man pages: {e}");
33 exit(1);
34 }
35 exit(0);
36 }
37 },
38 }
39 }
40}