Skip to content

Commit

Permalink
feat(config): read config file options from options node
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 4, 2023
1 parent a662765 commit 41b281e
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions crates/oro-config/src/kdl_source.rs
Expand Up @@ -11,18 +11,22 @@ impl Source for KdlSource {

fn collect(&self) -> Result<Map<String, Value>, ConfigError> {
let mut map = Map::new();
for node in self.0.nodes() {
let key = node.name().to_string();
if let Some(value) = node.get(0) {
let value = Value::new(
Some(&if let Some(str) = value.as_string() {
str.to_owned()
} else {
value.to_string()
}),
value_kind(value),
);
map.insert(key, value);
if let Some(config_node) = self.0.get("options") {
if let Some(children) = config_node.children() {
for node in children.nodes() {
let key = node.name().to_string();
if let Some(value) = node.get(0) {
let value = Value::new(
Some(&if let Some(str) = value.as_string() {
str.to_owned()
} else {
value.to_string()
}),
value_kind(value),
);
map.insert(key, value);
}
}
}
}
Ok(map)
Expand Down

0 comments on commit 41b281e

Please sign in to comment.