MCPcopy Create free account
hub / github.com/csskit/csskit / find_cks_hint

Function find_cks_hint

crates/csskit/src/commands/check.rs:298–313  ·  view source on GitHub ↗

Find the first `.cks` file in cwd, or fall back to `rules.cks`.

()

Source from the content-addressed store, hash-verified

296
297/// Find the first `.cks` file in cwd, or fall back to `rules.cks`.
298fn 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
315fn maybe_color<F: Fn(&str) -> String>(colors: bool, s: &str, f: F) -> String {
316 if colors { f(s) } else { s.to_string() }

Callers 2

hint_no_inputFunction · 0.85
hint_bad_sheetFunction · 0.85

Calls 3

collectMethod · 0.80
into_iterMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected