From bd868b9e489a166676048a5a321ed94008314da6 Mon Sep 17 00:00:00 2001 From: insign <1113045+insign@users.noreply.github.com> Date: Thu, 5 Mar 2026 03:27:04 +0000 Subject: [PATCH] refactor: unify command_starters array for command detection Exported `COMMAND_STARTERS` from `src/providers/mod.rs` and replaced the local hardcoded array in `src/cli/mod.rs` to ensure consistent command detection across the codebase. --- src/cli/mod.rs | 68 ++------------------------------------------ src/providers/mod.rs | 2 +- 2 files changed, 3 insertions(+), 67 deletions(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index be205cf..e47aac0 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -661,72 +661,8 @@ fn is_likely_command(text: &str) -> bool { } let first_word = text.split_whitespace().next().unwrap_or(""); - let command_starters = [ - "ls", - "cd", - "rm", - "cp", - "mv", - "mkdir", - "touch", - "cat", - "echo", - "grep", - "find", - "chmod", - "chown", - "sudo", - "apt", - "yum", - "brew", - "npm", - "yarn", - "cargo", - "git", - "docker", - "kubectl", - "systemctl", - "service", - "curl", - "wget", - "tar", - "zip", - "unzip", - "ssh", - "scp", - "rsync", - "ps", - "kill", - "top", - "htop", - "df", - "du", - "free", - "ping", - "traceroute", - "netstat", - "ss", - "iptables", - "ufw", - "python", - "python3", - "node", - "ruby", - "perl", - "php", - "java", - "go", - "rustc", - "gcc", - "g++", - "make", - "cmake", - "./", - "/", - "~", - ]; - - command_starters + + crate::providers::COMMAND_STARTERS .iter() .any(|cmd| first_word.starts_with(cmd)) } diff --git a/src/providers/mod.rs b/src/providers/mod.rs index 49a0298..c166222 100644 --- a/src/providers/mod.rs +++ b/src/providers/mod.rs @@ -16,7 +16,7 @@ use crate::config::Config; use anyhow::{anyhow, Result}; /// List of common command prefixes used to detect if a line is a shell command. -const COMMAND_STARTERS: &[&str] = &[ +pub const COMMAND_STARTERS: &[&str] = &[ "ls", "cd", "rm",