feat: includes executables in ~/.cargo/bin/ if present
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -124,6 +124,15 @@ version = "0.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "home"
|
||||||
|
version = "0.5.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is_terminal_polyfill"
|
name = "is_terminal_polyfill"
|
||||||
version = "1.70.0"
|
version = "1.70.0"
|
||||||
@@ -154,6 +163,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"fuzzy-matcher",
|
"fuzzy-matcher",
|
||||||
|
"home",
|
||||||
"sdl2",
|
"sdl2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ strip = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.4", features = ["derive"] }
|
clap = { version = "4.5.4", features = ["derive"] }
|
||||||
fuzzy-matcher = "0.3.7"
|
fuzzy-matcher = "0.3.7"
|
||||||
|
home = "0.5.9"
|
||||||
sdl2 = { version = "0.36.0", features = ["ttf"] }
|
sdl2 = { version = "0.36.0", features = ["ttf"] }
|
||||||
|
|||||||
@@ -5,11 +5,21 @@ pub fn get_executables() -> Result<Vec<String>, Box<dyn Error>> {
|
|||||||
|
|
||||||
get_files(Path::new("/usr/local"), &mut executables)?;
|
get_files(Path::new("/usr/local"), &mut executables)?;
|
||||||
get_files(Path::new("/bin"), &mut executables)?;
|
get_files(Path::new("/bin"), &mut executables)?;
|
||||||
|
match home::cargo_home() {
|
||||||
|
Ok(cargo_home) => {
|
||||||
|
get_files(&cargo_home.join("bin"), &mut executables)?;
|
||||||
|
}
|
||||||
|
Err(_) => (),
|
||||||
|
}
|
||||||
|
|
||||||
Ok(executables)
|
Ok(executables)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_files(path: &Path, files: &mut Vec<String>) -> Result<(), Box<dyn Error>> {
|
pub fn get_files(path: &Path, files: &mut Vec<String>) -> Result<(), Box<dyn Error>> {
|
||||||
|
if !path.exists() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let dirs = fs::read_dir(path)?;
|
let dirs = fs::read_dir(path)?;
|
||||||
|
|
||||||
for e in dirs {
|
for e in dirs {
|
||||||
|
|||||||
Reference in New Issue
Block a user