use crate::{active_children, unquote};
use asterust::config::ConfigLine;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct PrefixList {
pub name: String,
pub prefixes: Vec<String>,
pub apply_path: Option<String>,
}
pub(super) fn parse_prefix_list(name: &str, line: &ConfigLine) -> PrefixList {
let mut list = PrefixList {
name: name.to_string(),
prefixes: Vec::new(),
apply_path: None,
};
for child in active_children(line) {
if let Some(path) = child.arg("apply-path") {
list.apply_path = Some(unquote(path).to_string());
} else if !child.text.contains(' ') {
list.prefixes.push(child.text.clone());
}
}
list
}