Pi66

walrs
pywal but if its Fast-Minimal-Simple
git clone https://git.pi66.xyz/walrs

← back to log

remove clap and remove the auto complete

author: pixel2175
date: 2025-05-31 20:12
hash: ed4d7a1a5a251eafda7bff82fadf9b226d17fe7d

Diffstat:

D

src/completions.rs
67 ------------------------------
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
diff --git a/src/completions.rs b/src/completions.rs
deleted file mode 100644
index f496f0a..0000000
--- a/src/completions.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-use clap::CommandFactory;
-use clap_complete::{Shell, generate};
-use dirs_next::home_dir;
-use std::fs;
-use std::path::PathBuf;
-
-pub fn install_completions() -> std::io::Result<()> {
-    let shell = detect_shell();
-    let mut cmd = crate::Arg::command();
-    let app_name = cmd.get_name().to_string();
-
-    let (target_dir, completion_file) = match shell {
-        Shell::Bash => (
-            home_dir().unwrap().join(".bash_completion.d"),
-            PathBuf::from(app_name.clone()),
-        ),
-        Shell::Zsh => (
-            home_dir().unwrap().join(".zsh/completions"),
-            PathBuf::from(format!("_{}", app_name)),
-        ),
-        Shell::Fish => (
-            home_dir().unwrap().join(".config/fish/completions"),
-            PathBuf::from(format!("{}.fish", app_name)),
-        ),
-        Shell::PowerShell => (
-            home_dir().unwrap().join("Documents/PowerShell/Modules"),
-            PathBuf::from(format!("{}.ps1", app_name)),
-        ),
-        _ => {
-            return Err(std::io::Error::new(
-                std::io::ErrorKind::Unsupported,
-                "Unsupported shell",
-            ));
-        }
-    };
-
-    fs::create_dir_all(&target_dir)?;
-
-    let mut file = fs::File::create(target_dir.join(completion_file))?;
-    generate(shell, &mut cmd, app_name, &mut file);
-
-    Ok(())
-}
-
-fn detect_shell() -> Shell {
-    std::env::var("SHELL")
-        .ok()
-        .and_then(|shell| {
-            if shell.contains("zsh") {
-                Some(Shell::Zsh)
-            } else if shell.contains("bash") {
-                Some(Shell::Bash)
-            } else if shell.contains("fish") {
-                Some(Shell::Fish)
-            } else {
-                None
-            }
-        })
-        .unwrap_or_else(|| {
-            if cfg!(windows) {
-                Shell::PowerShell
-            } else {
-                // Default to bash if detection fails
-                Shell::Bash
-            }
-        })
-}