MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / parse_frontmatter_value

Function parse_frontmatter_value

crates/opencode-tool/src/skill.rs:100–119  ·  view source on GitHub ↗
(frontmatter: &str, key: &str)

Source from the content-addressed store, hash-verified

98}
99
100fn parse_frontmatter_value(frontmatter: &str, key: &str) -> Option<String> {
101 for line in frontmatter.lines() {
102 let trimmed = line.trim();
103 if trimmed.is_empty() || trimmed.starts_with('#') {
104 continue;
105 }
106 if let Some(value) = trimmed.strip_prefix(&format!("{key}:")) {
107 let value = value.trim();
108 if value.len() >= 2 {
109 if (value.starts_with('"') && value.ends_with('"'))
110 || (value.starts_with('\'') && value.ends_with('\''))
111 {
112 return Some(value[1..value.len() - 1].to_string());
113 }
114 }
115 return Some(value.to_string());
116 }
117 }
118 None
119}
120
121fn parse_skill_file(path: &Path) -> Option<SkillInfo> {
122 let raw = fs::read_to_string(path).ok()?;

Callers 1

parse_skill_fileFunction · 0.85

Calls 1

is_emptyMethod · 0.80

Tested by

no test coverage detected