Fix indentation for plist print

This commit is contained in:
Jackson Coxson
2025-02-26 09:58:26 -07:00
parent 1fd55f6317
commit b10815bb0b

View File

@@ -28,7 +28,13 @@ fn print_plist(p: &Value, indentation: usize) -> String {
Value::Array(vec) => { Value::Array(vec) => {
let items: Vec<String> = vec let items: Vec<String> = vec
.iter() .iter()
.map(|v| print_plist(v, indentation + 2)) .map(|v| {
format!(
"{}{}",
" ".repeat(indentation + 2),
print_plist(v, indentation + 2)
)
})
.collect(); .collect();
format!("[\n{}\n{}]", items.join(",\n"), indent) format!("[\n{}\n{}]", items.join(",\n"), indent)
} }
@@ -44,7 +50,7 @@ fn print_plist(p: &Value, indentation: usize) -> String {
) )
}) })
.collect(); .collect();
format!("{}{{\n{}\n{}}}", indent, items.join(",\n"), indent) format!("{{\n{}\n{}}}", items.join(",\n"), indent)
} }
Value::Boolean(b) => format!("{}", b), Value::Boolean(b) => format!("{}", b),
Value::Data(vec) => { Value::Data(vec) => {
@@ -55,7 +61,11 @@ fn print_plist(p: &Value, indentation: usize) -> String {
.map(|b| format!("{:02X}", b)) .map(|b| format!("{:02X}", b))
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(" "); .join(" ");
if len > 20 {
format!("Data({}... Len: {})", preview, len) format!("Data({}... Len: {})", preview, len)
} else {
format!("Data({} Len: {})", preview, len)
}
} }
Value::Date(date) => format!("Date({})", date.to_xml_format()), Value::Date(date) => format!("Date({})", date.to_xml_format()),
Value::Real(f) => format!("{}", f), Value::Real(f) => format!("{}", f),