mirror of
https://codeberg.org/axtlos/deskwhich.git
synced 2024-12-25 06:27:44 +01:00
fix indentation
This commit is contained in:
parent
cbe8a0cdf4
commit
04bd3c4653
1 changed files with 28 additions and 28 deletions
56
src/main.rs
56
src/main.rs
|
@ -15,39 +15,39 @@ fn main() {
|
|||
|
||||
let mut found = false;
|
||||
let home = match env::var("HOME") {
|
||||
Ok(var) => var,
|
||||
Err(_) => exit(1),
|
||||
Ok(var) => var,
|
||||
Err(_) => exit(1),
|
||||
};
|
||||
for dirs in data_dirs {
|
||||
if (dirs.starts_with(&home) && cli.skip_home) || (dirs.starts_with(".") && cli.skip_dot) {
|
||||
continue
|
||||
}
|
||||
|
||||
let files = match fs::read_dir(format!("{}/applications",dirs)) {
|
||||
Ok(file) => file,
|
||||
Err(_) => continue,
|
||||
};
|
||||
for file in files {
|
||||
let desktop_file = format!("{}", file.as_ref().unwrap().file_name().into_string().unwrap());
|
||||
let mut name = desktop_file.split(".");
|
||||
if name.find(|x| *x == cli.search.strip_suffix(".desktop").unwrap_or(&cli.search)).is_some() {
|
||||
let path = file.as_ref().unwrap().path();
|
||||
let out = if cli.show_tilde {
|
||||
format!("{}", path.display().to_string().replace(&home, "~"))
|
||||
} else {
|
||||
path.display().to_string()
|
||||
};
|
||||
println!("{}", out);
|
||||
found = true;
|
||||
if !cli.all {
|
||||
return
|
||||
}
|
||||
if (dirs.starts_with(&home) && cli.skip_home) || (dirs.starts_with(".") && cli.skip_dot) {
|
||||
continue
|
||||
}
|
||||
|
||||
let files = match fs::read_dir(format!("{}/applications",dirs)) {
|
||||
Ok(file) => file,
|
||||
Err(_) => continue,
|
||||
};
|
||||
for file in files {
|
||||
let desktop_file = format!("{}", file.as_ref().unwrap().file_name().into_string().unwrap());
|
||||
let mut name = desktop_file.split(".");
|
||||
if name.find(|x| *x == cli.search.strip_suffix(".desktop").unwrap_or(&cli.search)).is_some() {
|
||||
let path = file.as_ref().unwrap().path();
|
||||
let out = if cli.show_tilde {
|
||||
format!("{}", path.display().to_string().replace(&home, "~"))
|
||||
} else {
|
||||
path.display().to_string()
|
||||
};
|
||||
println!("{}", out);
|
||||
found = true;
|
||||
if !cli.all {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
eprintln!("No {} in ({})", args[1], xdg_data_dirs);
|
||||
exit(1);
|
||||
eprintln!("No {} in ({})", args[1], xdg_data_dirs);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue