mirror of
https://codeberg.org/iff/pay-respects.git
synced 2025-10-05 16:12:54 +02:00
chore: clippy fixes
This commit is contained in:
125
core/src/data.rs
125
core/src/data.rs
@@ -65,80 +65,73 @@ impl Data {
|
||||
#[cfg(debug_assertions)]
|
||||
eprintln!("lib_dir: {:?}", lib_dir);
|
||||
|
||||
if lib_dir.is_none() {
|
||||
(executables, modules, fallbacks) = {
|
||||
let path_executables = get_path_files();
|
||||
let mut executables = vec![];
|
||||
let mut modules = vec![];
|
||||
let mut fallbacks = vec![];
|
||||
for exe in path_executables {
|
||||
if exe.starts_with("_pay-respects-module-") {
|
||||
modules.push(exe.to_string());
|
||||
} else if exe.starts_with("_pay-respects-fallback-") {
|
||||
fallbacks.push(exe.to_string());
|
||||
} else {
|
||||
executables.push(exe.to_string());
|
||||
}
|
||||
}
|
||||
modules.sort_unstable();
|
||||
fallbacks.sort_unstable();
|
||||
if alias.is_some() {
|
||||
let alias = alias.as_ref().unwrap();
|
||||
for command in alias.keys() {
|
||||
if executables.contains(command) {
|
||||
continue;
|
||||
}
|
||||
executables.push(command.to_string());
|
||||
(executables, modules, fallbacks) = if let Some(lib_dir) = lib_dir {
|
||||
let mut modules = vec![];
|
||||
let mut fallbacks = vec![];
|
||||
let mut executables = get_path_files();
|
||||
if let Some(alias) = &alias {
|
||||
for command in alias.keys() {
|
||||
if executables.contains(command) {
|
||||
continue;
|
||||
}
|
||||
executables.push(command.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
(executables, modules, fallbacks)
|
||||
};
|
||||
let path = lib_dir.split(path_env_sep()).collect::<Vec<&str>>();
|
||||
|
||||
for p in path {
|
||||
#[cfg(windows)]
|
||||
let p = path_convert(p);
|
||||
|
||||
let files = match std::fs::read_dir(p) {
|
||||
Ok(files) => files,
|
||||
Err(_) => continue,
|
||||
};
|
||||
for file in files {
|
||||
let file = file.unwrap();
|
||||
let file_name = file.file_name().into_string().unwrap();
|
||||
let file_path = file.path();
|
||||
|
||||
if file_name.starts_with("_pay-respects-module-") {
|
||||
modules.push(file_path.to_string_lossy().to_string());
|
||||
} else if file_name.starts_with("_pay-respects-fallback-") {
|
||||
fallbacks.push(file_path.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modules.sort_unstable();
|
||||
fallbacks.sort_unstable();
|
||||
|
||||
(executables, modules, fallbacks)
|
||||
} else {
|
||||
(executables, modules, fallbacks) = {
|
||||
let mut modules = vec![];
|
||||
let mut fallbacks = vec![];
|
||||
let lib_dir = lib_dir.unwrap();
|
||||
let mut executables = get_path_files();
|
||||
if alias.is_some() {
|
||||
let alias = alias.as_ref().unwrap();
|
||||
for command in alias.keys() {
|
||||
if executables.contains(command) {
|
||||
continue;
|
||||
}
|
||||
executables.push(command.to_string());
|
||||
}
|
||||
let path_executables = get_path_files();
|
||||
let mut executables = vec![];
|
||||
let mut modules = vec![];
|
||||
let mut fallbacks = vec![];
|
||||
for exe in path_executables {
|
||||
if exe.starts_with("_pay-respects-module-") {
|
||||
modules.push(exe.to_string());
|
||||
} else if exe.starts_with("_pay-respects-fallback-") {
|
||||
fallbacks.push(exe.to_string());
|
||||
} else {
|
||||
executables.push(exe.to_string());
|
||||
}
|
||||
|
||||
let path = lib_dir.split(path_env_sep()).collect::<Vec<&str>>();
|
||||
|
||||
for p in path {
|
||||
#[cfg(windows)]
|
||||
let p = path_convert(p);
|
||||
|
||||
let files = match std::fs::read_dir(p) {
|
||||
Ok(files) => files,
|
||||
Err(_) => continue,
|
||||
};
|
||||
for file in files {
|
||||
let file = file.unwrap();
|
||||
let file_name = file.file_name().into_string().unwrap();
|
||||
let file_path = file.path();
|
||||
|
||||
if file_name.starts_with("_pay-respects-module-") {
|
||||
modules.push(file_path.to_string_lossy().to_string());
|
||||
} else if file_name.starts_with("_pay-respects-fallback-") {
|
||||
fallbacks.push(file_path.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
modules.sort_unstable();
|
||||
fallbacks.sort_unstable();
|
||||
if let Some(alias) = &alias {
|
||||
for command in alias.keys() {
|
||||
if executables.contains(command) {
|
||||
continue;
|
||||
}
|
||||
executables.push(command.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
modules.sort_unstable();
|
||||
fallbacks.sort_unstable();
|
||||
|
||||
(executables, modules, fallbacks)
|
||||
};
|
||||
}
|
||||
(executables, modules, fallbacks)
|
||||
};
|
||||
|
||||
let builtins = builtin_commands(&shell);
|
||||
executables.extend(builtins.clone());
|
||||
|
@@ -83,8 +83,8 @@ pub fn suggest_candidates(data: &mut Data) {
|
||||
}
|
||||
for fallback in fallbacks {
|
||||
let candidates = module_output(data, fallback);
|
||||
if candidates.is_some() {
|
||||
add_candidates_no_dup(command, &mut final_candidates, &candidates.unwrap());
|
||||
if let Some(candidates) = candidates {
|
||||
add_candidates_no_dup(command, &mut final_candidates, &candidates);
|
||||
data.candidates = final_candidates
|
||||
.iter()
|
||||
.map(|s| shell_syntax(shell, s))
|
||||
|
@@ -80,16 +80,16 @@ pub fn command(suggest: &mut String, split_command: &[String]) {
|
||||
};
|
||||
let mut end_index;
|
||||
let parsed_end = end.parse::<i32>();
|
||||
if parsed_end.is_err() {
|
||||
end_index = split_command.len() as i32;
|
||||
} else {
|
||||
end_index = parsed_end.unwrap();
|
||||
if let Ok(end) = parsed_end {
|
||||
end_index = end;
|
||||
if end_index < 0 {
|
||||
end_index += split_command.len() as i32 + 1;
|
||||
} else {
|
||||
end_index += 1;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
end_index = split_command.len() as i32;
|
||||
}
|
||||
|
||||
let command = split_command[start_index as usize..end_index as usize].join(" ");
|
||||
|
||||
@@ -130,15 +130,14 @@ pub fn typo(suggest: &mut String, split_command: &[String], executables: &[Strin
|
||||
start
|
||||
};
|
||||
let end = end.parse::<i32>();
|
||||
let end_index = if end.is_err() {
|
||||
split_command.len() as i32
|
||||
} else {
|
||||
let end = end.unwrap();
|
||||
let end_index = if let Ok(end) = end {
|
||||
if end < 0 {
|
||||
split_command.len() as i32 + end + 1
|
||||
} else {
|
||||
end + 1
|
||||
}
|
||||
} else {
|
||||
split_command.len() as i32
|
||||
};
|
||||
|
||||
start_index as usize..end_index as usize
|
||||
|
@@ -175,15 +175,14 @@ pub fn typo(suggest: &mut String, replace_list: &mut Vec<TokenStream2>) {
|
||||
start.to_string()
|
||||
};
|
||||
let end = end.parse::<i32>();
|
||||
let end_string = if end.is_err() {
|
||||
String::from("split.len()")
|
||||
} else {
|
||||
let end = end.unwrap();
|
||||
let end_string = if let Ok(end) = end {
|
||||
if end < 0 {
|
||||
format!("split.len() {}", end + 1)
|
||||
} else {
|
||||
(end + 1).to_string()
|
||||
}
|
||||
} else {
|
||||
String::from("split.len()")
|
||||
};
|
||||
|
||||
format!("{}..{}", start_string, end_string)
|
||||
|
Reference in New Issue
Block a user