From a510673123180179e9884b2152752322949fd4c6 Mon Sep 17 00:00:00 2001 From: Integral Date: Thu, 31 Oct 2024 22:15:28 +0800 Subject: [PATCH] refactor: use for loop to generate completions file (#1869) --- yazi-boot/build.rs | 9 ++++----- yazi-cli/build.rs | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/yazi-boot/build.rs b/yazi-boot/build.rs index a4ab04fd..c84a976c 100644 --- a/yazi-boot/build.rs +++ b/yazi-boot/build.rs @@ -22,11 +22,10 @@ fn main() -> Result<(), Box> { let out = "completions"; std::fs::create_dir_all(out)?; - generate_to(Shell::Bash, cmd, bin, out)?; - generate_to(Shell::Fish, cmd, bin, out)?; - generate_to(Shell::Zsh, cmd, bin, out)?; - generate_to(Shell::Elvish, cmd, bin, out)?; - generate_to(Shell::PowerShell, cmd, bin, out)?; + for sh in [Shell::Bash, Shell::Fish, Shell::Zsh, Shell::Elvish, Shell::PowerShell] { + generate_to(sh, cmd, bin, out)?; + } + generate_to(clap_complete_nushell::Nushell, cmd, bin, out)?; generate_to(clap_complete_fig::Fig, cmd, bin, out)?; diff --git a/yazi-cli/build.rs b/yazi-cli/build.rs index f9f33a67..0ae2f659 100644 --- a/yazi-cli/build.rs +++ b/yazi-cli/build.rs @@ -22,11 +22,10 @@ fn main() -> Result<(), Box> { let out = "completions"; std::fs::create_dir_all(out)?; - generate_to(Shell::Bash, cmd, bin, out)?; - generate_to(Shell::Fish, cmd, bin, out)?; - generate_to(Shell::Zsh, cmd, bin, out)?; - generate_to(Shell::Elvish, cmd, bin, out)?; - generate_to(Shell::PowerShell, cmd, bin, out)?; + for sh in [Shell::Bash, Shell::Fish, Shell::Zsh, Shell::Elvish, Shell::PowerShell] { + generate_to(sh, cmd, bin, out)?; + } + generate_to(clap_complete_nushell::Nushell, cmd, bin, out)?; generate_to(clap_complete_fig::Fig, cmd, bin, out)?;