MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / parse_control_file

Function parse_control_file

xtask/src/extension_catalog.rs:1227–1258  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

1225}
1226
1227fn parse_control_file(path: &Path) -> Result<ControlMetadata> {
1228 let text = fs::read_to_string(path).with_context(|| format!("read {}", path.display()))?;
1229 let mut control = ControlMetadata::default();
1230 for line in text.lines() {
1231 let line = line.split('#').next().unwrap_or_default().trim();
1232 if line.is_empty() {
1233 continue;
1234 }
1235 let Some((key, value)) = line.split_once('=') else {
1236 continue;
1237 };
1238 let key = key.trim();
1239 let value = strip_quoted(value.trim())
1240 .unwrap_or_else(|| value.trim().trim_matches('"'))
1241 .to_owned();
1242 match key {
1243 "default_version" => control.default_version = Some(value),
1244 "module_pathname" => control.module_pathname = Some(value),
1245 "requires" => {
1246 control.requires = value
1247 .split(',')
1248 .map(|item| item.trim().trim_matches('"').to_owned())
1249 .filter(|item| !item.is_empty())
1250 .collect();
1251 }
1252 "relocatable" => control.relocatable = Some(value),
1253 "schema" => control.schema = Some(value),
1254 _ => {}
1255 }
1256 }
1257 Ok(control)
1258}
1259
1260fn discover_dependencies(id: &str, control: Option<&ControlMetadata>) -> Vec<String> {
1261 let mut dependencies = BTreeSet::new();

Callers 1

discover_catalogFunction · 0.85

Calls 1

strip_quotedFunction · 0.85

Tested by

no test coverage detected