mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-04-20 20:26:50 +00:00
Show subform entries in tree subcommand
This commit is contained in:
parent
c514005182
commit
1f51d3e994
@ -289,6 +289,27 @@ impl Requires for DataForm {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
result.append(referenced_forms);
|
result.append(referenced_forms);
|
||||||
|
|
||||||
|
let sub_forms = &mut self
|
||||||
|
.entries
|
||||||
|
.entry
|
||||||
|
.iter()
|
||||||
|
.filter(|&entry| entry.get_type() == "subform")
|
||||||
|
.filter_map(|entry| match &entry.referenced_data_form {
|
||||||
|
Some(name) => Some(name),
|
||||||
|
None => None,
|
||||||
|
})
|
||||||
|
.collect::<HashSet<_>>()
|
||||||
|
.into_iter()
|
||||||
|
.map(|entry| match all.find_data_form(entry.as_str()) {
|
||||||
|
Some(contained) => Requirement::DataFormSubform(contained),
|
||||||
|
None => match all.find_unterformular(entry.as_str()) {
|
||||||
|
Some(contained) => Requirement::UnterformularSubform(contained),
|
||||||
|
None => Requirement::ExternalUnterformularSubform(entry.to_string()),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
result.append(sub_forms);
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,6 +352,12 @@ impl Requires for DataForm {
|
|||||||
| Requirement::ExternalUnterformularReference(_) => {
|
| Requirement::ExternalUnterformularReference(_) => {
|
||||||
Some(format!(" > {}\n", entry.to_string()))
|
Some(format!(" > {}\n", entry.to_string()))
|
||||||
}
|
}
|
||||||
|
Requirement::DataFormSubform(_)
|
||||||
|
| Requirement::ExternalDataFormSubform(_)
|
||||||
|
| Requirement::UnterformularSubform(_)
|
||||||
|
| Requirement::ExternalUnterformularSubform(_) => {
|
||||||
|
Some(format!(" $ {}\n", entry.to_string()))
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.filter(Option::is_some)
|
.filter(Option::is_some)
|
||||||
|
@ -40,6 +40,12 @@ pub enum Requirement<'a> {
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
ExternalDataFormReference(String),
|
ExternalDataFormReference(String),
|
||||||
ExternalUnterformularReference(String),
|
ExternalUnterformularReference(String),
|
||||||
|
|
||||||
|
DataFormSubform(&'a DataForm),
|
||||||
|
UnterformularSubform(&'a Unterformular),
|
||||||
|
#[allow(dead_code)]
|
||||||
|
ExternalDataFormSubform(String),
|
||||||
|
ExternalUnterformularSubform(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for Requirement<'_> {
|
impl ToString for Requirement<'_> {
|
||||||
@ -61,6 +67,14 @@ impl ToString for Requirement<'_> {
|
|||||||
Requirement::ExternalUnterformularReference(name) => {
|
Requirement::ExternalUnterformularReference(name) => {
|
||||||
format!("Unterformular (-) '{}' - hier nicht enthalten", name)
|
format!("Unterformular (-) '{}' - hier nicht enthalten", name)
|
||||||
}
|
}
|
||||||
|
Requirement::DataFormSubform(item) => item.to_listed_string(),
|
||||||
|
Requirement::UnterformularSubform(item) => item.to_listed_string(),
|
||||||
|
Requirement::ExternalDataFormSubform(name) => {
|
||||||
|
format!("Formular (-) '{}' - hier nicht enthalten", name)
|
||||||
|
}
|
||||||
|
Requirement::ExternalUnterformularSubform(name) => {
|
||||||
|
format!("Unterformular (-) '{}' - hier nicht enthalten", name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,6 +293,27 @@ impl Requires for Unterformular {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
result.append(referenced_forms);
|
result.append(referenced_forms);
|
||||||
|
|
||||||
|
let sub_forms = &mut self
|
||||||
|
.entries
|
||||||
|
.entry
|
||||||
|
.iter()
|
||||||
|
.filter(|&entry| entry.get_type() == "subform")
|
||||||
|
.filter_map(|entry| match &entry.referenced_data_form {
|
||||||
|
Some(name) => Some(name),
|
||||||
|
None => None,
|
||||||
|
})
|
||||||
|
.collect::<HashSet<_>>()
|
||||||
|
.into_iter()
|
||||||
|
.map(|entry| match all.find_data_form(entry.as_str()) {
|
||||||
|
Some(contained) => Requirement::DataFormSubform(contained),
|
||||||
|
None => match all.find_unterformular(entry.as_str()) {
|
||||||
|
Some(contained) => Requirement::UnterformularSubform(contained),
|
||||||
|
None => Requirement::ExternalUnterformularSubform(entry.to_string()),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
result.append(sub_forms);
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,6 +355,12 @@ impl Requires for Unterformular {
|
|||||||
| Requirement::ExternalUnterformularReference(_) => {
|
| Requirement::ExternalUnterformularReference(_) => {
|
||||||
Some(format!(" > {}\n", entry.to_string()))
|
Some(format!(" > {}\n", entry.to_string()))
|
||||||
}
|
}
|
||||||
|
Requirement::DataFormSubform(_)
|
||||||
|
| Requirement::ExternalDataFormSubform(_)
|
||||||
|
| Requirement::UnterformularSubform(_)
|
||||||
|
| Requirement::ExternalUnterformularSubform(_) => {
|
||||||
|
Some(format!(" $ {}\n", entry.to_string()))
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.filter(Option::is_some)
|
.filter(Option::is_some)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user