diff --git a/utils/src/evals.rs b/utils/src/evals.rs index f7b474b..f6263e1 100644 --- a/utils/src/evals.rs +++ b/utils/src/evals.rs @@ -37,6 +37,8 @@ pub fn cmd_regex(regex: &str, command: &str) -> String { cmd.join(" ") } +/// Returns the output of a shell command as a vector of strings +/// Each string is a line of output pub fn eval_shell_command(shell: &str, command: &str) -> Vec { let output = std::process::Command::new(shell) .arg("-c") @@ -51,6 +53,7 @@ pub fn eval_shell_command(shell: &str, command: &str) -> Vec { .collect::>() } +/// Split the full command into command and arguments pub fn split_command(command: &str) -> Vec { #[cfg(debug_assertions)] eprintln!("command: {command}"); @@ -114,11 +117,12 @@ pub fn best_matches_path(typo: &str, executables: &[String]) -> Option) -> Option { let threshold = threshold.unwrap_or(2); let mut min_distance = typo.chars().count() / threshold + 1; @@ -139,6 +143,8 @@ pub fn find_similar(typo: &str, candidates: &[String], threshold: Option) None } +/// Similar to `find_similar`, but returns a vector of all candidates +/// with the same minimum distance pub fn find_similars( typo: &str, candidates: &[String],