From 3d80ecf9b89cc5ba58a6367c341c65f0a3ef104c Mon Sep 17 00:00:00 2001 From: iff Date: Wed, 9 Apr 2025 15:53:06 +0200 Subject: [PATCH] chore: lib docs --- utils/src/evals.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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],