From b8018ccc6c20b41c83ea1cecd0106fa315322749 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sun, 21 Mar 2021 12:12:36 -0700 Subject: [PATCH] Prepare for making shell completion functionality generic over shell This change prepares the shell-complete utility program to be generic over the shell to use. Specifically, we rename the generate_bash function to generate_for_shell and pass in the shell to use. --- var/shell-complete.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/var/shell-complete.rs b/var/shell-complete.rs index 0cb66b7d..b3ceb11f 100644 --- a/var/shell-complete.rs +++ b/var/shell-complete.rs @@ -41,17 +41,17 @@ struct Args { command: String, } -fn generate_bash(command: &str, output: &mut W) +fn generate_for_shell(command: &str, shell: clap::Shell, output: &mut W) where W: io::Write, { let mut app = nitrocli::Args::clap(); - app.gen_completions_to(command, clap::Shell::Bash, output); + app.gen_completions_to(command, shell, output); } fn main() { let args = Args::from_args(); - generate_bash(&args.command, &mut io::stdout()) + generate_for_shell(&args.command, clap::Shell::Bash, &mut io::stdout()) } #[cfg(test)] @@ -92,7 +92,7 @@ mod tests { W: ExactSizeIterator, { let mut buffer = Vec::new(); - generate_bash("nitrocli", &mut buffer); + generate_for_shell("nitrocli", clap::Shell::Bash, &mut buffer); let script = String::from_utf8(buffer).unwrap(); let command = format!(