1
0
mirror of https://github.com/pcvolkmer/osc-variant.git synced 2025-07-03 17:22:54 +00:00

Add subcommands 'list' and 'modify'

This commit is contained in:
2023-06-03 15:27:09 +02:00
parent 5681b1dee3
commit ca145f5e4b
9 changed files with 290 additions and 48 deletions

View File

@ -55,6 +55,15 @@ pub struct DataCatalogue {
ordner: Ordner,
}
impl DataCatalogue {
pub fn to_listed_string(&self) -> String {
format!(
"Datenkatalog '{}' in Revision '{}'",
self.name, self.revision
)
}
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct Entries {

View File

@ -160,6 +160,10 @@ impl DataForm {
})
}
}
pub fn to_listed_string(&self) -> String {
format!("Formular '{}' in Revision '{}'", self.name, self.revision)
}
}
#[derive(Serialize, Deserialize, Debug)]

View File

@ -22,6 +22,7 @@
* SOFTWARE.
*/
use console::style;
use serde::{Deserialize, Serialize};
use crate::model::data_catalogue::DataCatalogue;
@ -47,6 +48,49 @@ impl OnkostarEditor {
data_form.apply_variant();
})
}
pub fn list_forms(&self) {
println!(
"{}",
style("In der Datei sind folgende Inhalte gespeichert\n").bold()
);
println!(
"{} {}",
self.editor.property_catalogue.len(),
style("Merkmalskataloge").underlined()
);
self.editor
.property_catalogue
.iter()
.for_each(|data_form| println!("{}", data_form.to_listed_string()));
println!(
"\n{} {}",
self.editor.data_catalogue.len(),
style("Datenkataloge").underlined()
);
self.editor
.data_catalogue
.iter()
.for_each(|data_form| println!("{}", data_form.to_listed_string()));
println!(
"\n{} {}",
self.editor.data_form.len(),
style("Formulare").underlined()
);
self.editor
.data_form
.iter()
.for_each(|data_form| println!("{}", data_form.to_listed_string()));
println!(
"\n{} {}",
self.editor.unterformular.len(),
style("Unterformulare").underlined()
);
self.editor
.unterformular
.iter()
.for_each(|data_form| println!("{}", data_form.to_listed_string()));
}
}
#[derive(Serialize, Deserialize, Debug)]

View File

@ -52,6 +52,15 @@ pub struct PropertyCatalogue {
ordner: Ordner,
}
impl PropertyCatalogue {
pub fn to_listed_string(&self) -> String {
format!(
"Merkmalskatalog '{}' in Revision '{}'",
self.name, self.revision
)
}
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct Versions {

View File

@ -22,6 +22,7 @@
* SOFTWARE.
*/
use console::style;
use serde::{Deserialize, Serialize};
use crate::model::Ordner;
@ -168,6 +169,21 @@ impl Unterformular {
})
}
}
pub fn to_listed_string(&self) -> String {
if self.hat_unterformulare {
return format!(
"Unterformular '{}' in Revision '{}' {}",
self.name,
self.revision,
style("Unterformular mit Markierung 'hat Unterformulare'!").red()
);
}
format!(
"Unterformular '{}' in Revision '{}'",
self.name, self.revision
)
}
}
#[derive(Serialize, Deserialize, Debug)]