aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-10 16:19:45 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-10 16:19:45 +0800
commit2d0aae4b2d595ced100f7a2ec8d13b872a5eb65e (patch)
tree9df306e1185470655f3ed43fad866cf02430160f /mingling_core/src
parent61b770ca958afa7e5eca4c50f5e06bdf3ed7a94a (diff)
refactor: simplify macro parsing code and fix clippy warnings
Diffstat (limited to 'mingling_core/src')
-rw-r--r--mingling_core/src/build/comp.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/mingling_core/src/build/comp.rs b/mingling_core/src/build/comp.rs
index 2abb1e1..c1000c7 100644
--- a/mingling_core/src/build/comp.rs
+++ b/mingling_core/src/build/comp.rs
@@ -10,6 +10,7 @@ const TMPL_COMP_FISH: &str = include_str!("../../tmpls/comps/fish.fish");
const TMPL_COMP_PWSH: &str = include_str!("../../tmpls/comps/pwsh.ps1");
/// Generate shell completion scripts for a given binary name.
+///
/// On Windows, generates `PowerShell` completion.
/// On Linux, generates Zsh, Bash, and Fish completions.
/// Scripts are written to the `OUT_DIR` (or `target/` if `OUT_DIR` is not set).
@@ -63,7 +64,7 @@ pub fn build_comp_scripts(name: &str) -> Result<(), std::io::Error> {
/// ```
pub fn build_comp_script(shell_flag: &ShellFlag, bin_name: &str) -> Result<(), std::io::Error> {
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
- let target_dir = out_dir.join("../../../").clone();
+ let target_dir = out_dir.join("../../../");
build_comp_script_to(shell_flag, bin_name, &target_dir.to_string_lossy())
}
@@ -116,13 +117,12 @@ pub fn build_comp_script_to_file(
std::fs::write(output_path.into(), tmpl.to_string())
}
-fn get_tmpl(shell_flag: &ShellFlag) -> (&'static str, &'static str) {
+const fn get_tmpl(shell_flag: &ShellFlag) -> (&'static str, &'static str) {
match shell_flag {
- ShellFlag::Bash => (TMPL_COMP_BASH, ".sh"),
+ ShellFlag::Bash | ShellFlag::Other(_) => (TMPL_COMP_BASH, ".sh"),
ShellFlag::Zsh => (TMPL_COMP_ZSH, ".zsh"),
ShellFlag::Fish => (TMPL_COMP_FISH, ".fish"),
ShellFlag::Powershell => (TMPL_COMP_PWSH, ".ps1"),
- ShellFlag::Other(_) => (TMPL_COMP_BASH, ".sh"),
}
}