MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / extract_description

Function extract_description

crates/opencode-command/src/lib.rs:298–315  ·  view source on GitHub ↗

Extract description from markdown (first line after # if present)

(content: &str)

Source from the content-addressed store, hash-verified

296
297/// Extract description from markdown (first line after # if present)
298fn extract_description(content: &str) -> Option<String> {
299 let lines: Vec<&str> = content.lines().collect();
300
301 for line in lines {
302 let trimmed = line.trim();
303 if trimmed.starts_with('#') {
304 return Some(trimmed.trim_start_matches('#').trim().to_string());
305 }
306 if !trimmed.is_empty() && !trimmed.starts_with("<!--") {
307 return Some(format!(
308 "Command: {}",
309 trimmed.chars().take(50).collect::<String>()
310 ));
311 }
312 }
313
314 None
315}
316
317#[cfg(test)]
318mod tests {

Callers 1

load_from_directoryMethod · 0.85

Calls 1

is_emptyMethod · 0.80

Tested by

no test coverage detected