MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / str_array

Function str_array

atomic-canonical/src/lift.rs:336–349  ·  view source on GitHub ↗
(fm: &Map<String, Value>, key: &str)

Source from the content-addressed store, hash-verified

334}
335
336fn str_array(fm: &Map<String, Value>, key: &str) -> Vec<String> {
337 match fm.get(key) {
338 Some(Value::Array(items)) => items
339 .iter()
340 .filter_map(|v| v.as_str().map(str::to_string))
341 .collect(),
342 Some(Value::String(s)) if !s.is_empty() => s
343 .split(',')
344 .map(|p| p.trim().to_string())
345 .filter(|p| !p.is_empty())
346 .collect(),
347 _ => Vec::new(),
348 }
349}
350
351/// Minimal frontmatter splitter for a full markdown document:
352/// `---\n<key: value lines>\n---\n<body>`. Enough for templates and the CLI;

Callers 1

lift_intentFunction · 0.70

Calls 4

getMethod · 0.65
iterMethod · 0.45
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected