1pub mod paths;
2pub mod session;
3pub mod tracing;
4
5use std::path::Path;
6
7pub fn is_git_repo(path: &Path) -> bool {
9 let git_dir = path.join(".git");
10 git_dir.exists() && git_dir.is_dir()
11}
12
13pub fn get_platform() -> String {
15 #[cfg(target_os = "linux")]
16 return "linux".to_string();
17
18 #[cfg(target_os = "macos")]
19 return "macos".to_string();
20
21 #[cfg(target_os = "windows")]
22 return "windows".to_string();
23
24 #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
25 return "unknown".to_string();
26}
27
28pub fn escape_regex(s: &str) -> String {
30 let special_chars = r"[\^$.|?*+(){}";
31 let mut result = String::with_capacity(s.len() * 2);
32
33 for c in s.chars() {
34 if special_chars.contains(c) {
35 result.push('\\');
36 }
37 result.push(c);
38 }
39
40 result
41}