Find the first `.cks` file in cwd, or fall back to `rules.cks`.
()
| 296 | |
| 297 | /// Find the first `.cks` file in cwd, or fall back to `rules.cks`. |
| 298 | fn find_cks_hint() -> String { |
| 299 | if let Ok(entries) = fs::read_dir(".") { |
| 300 | let mut names: Vec<String> = entries |
| 301 | .flatten() |
| 302 | .filter_map(|e| { |
| 303 | let name = e.file_name().to_string_lossy().into_owned(); |
| 304 | name.ends_with(".cks").then_some(name) |
| 305 | }) |
| 306 | .collect(); |
| 307 | names.sort(); |
| 308 | if let Some(name) = names.into_iter().next() { |
| 309 | return name; |
| 310 | } |
| 311 | } |
| 312 | "rules.cks".to_string() |
| 313 | } |
| 314 | |
| 315 | fn maybe_color<F: Fn(&str) -> String>(colors: bool, s: &str, f: F) -> String { |
| 316 | if colors { f(s) } else { s.to_string() } |
no test coverage detected