mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-04-19 19:56:50 +00:00
Issue #15: Implement check subcommand cli
This commit is contained in:
parent
dce2a5cdda
commit
a55db66e57
@ -101,6 +101,8 @@ pub enum SubCommand {
|
|||||||
#[arg(long = "strict", help = "Strikter Vergleich des Inhalts")]
|
#[arg(long = "strict", help = "Strikter Vergleich des Inhalts")]
|
||||||
strict: bool,
|
strict: bool,
|
||||||
},
|
},
|
||||||
|
#[command(about = "Überprüfe OSC-Datei auf bekannte Fehler")]
|
||||||
|
Check { file: String },
|
||||||
#[cfg(feature = "unzip-osb")]
|
#[cfg(feature = "unzip-osb")]
|
||||||
#[command(about = "Entpackt eine OSB-Datei")]
|
#[command(about = "Entpackt eine OSB-Datei")]
|
||||||
UnzipOsb {
|
UnzipOsb {
|
||||||
|
@ -40,6 +40,7 @@ use sha256::digest;
|
|||||||
|
|
||||||
use crate::cli::{Cli, SubCommand};
|
use crate::cli::{Cli, SubCommand};
|
||||||
use crate::model::onkostar_editor::OnkostarEditor;
|
use crate::model::onkostar_editor::OnkostarEditor;
|
||||||
|
use crate::model::Checkable;
|
||||||
use crate::profile::Profile;
|
use crate::profile::Profile;
|
||||||
|
|
||||||
mod cli;
|
mod cli;
|
||||||
@ -257,6 +258,12 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
SubCommand::Check { file } => {
|
||||||
|
read_inputfile(file)?
|
||||||
|
.check()
|
||||||
|
.iter()
|
||||||
|
.for_each(|check_notice| println!("{}", check_notice));
|
||||||
|
}
|
||||||
#[cfg(feature = "unzip-osb")]
|
#[cfg(feature = "unzip-osb")]
|
||||||
SubCommand::UnzipOsb {
|
SubCommand::UnzipOsb {
|
||||||
file,
|
file,
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::hash_map::DefaultHasher;
|
use std::collections::hash_map::DefaultHasher;
|
||||||
use std::fmt::Debug;
|
use std::fmt::{Debug, Display, Formatter};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
|
||||||
use crate::model::requirements::Requires;
|
use crate::model::requirements::Requires;
|
||||||
@ -329,3 +329,25 @@ pub trait FolderContent {
|
|||||||
"ONKOSTAR Bibliothek" == self.get_library_folder()
|
"ONKOSTAR Bibliothek" == self.get_library_folder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum CheckNotice {
|
||||||
|
/// This will result in Error if importing file
|
||||||
|
Error { code: String, description: String },
|
||||||
|
/// Other known issues
|
||||||
|
Warning { description: String },
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for CheckNotice {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
CheckNotice::Error { code, description } => {
|
||||||
|
write!(f, "[ERROR] ({}) {}", code, description)
|
||||||
|
}
|
||||||
|
CheckNotice::Warning { description } => write!(f, "[WARNING] {}", description),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Checkable {
|
||||||
|
fn check(&self) -> Vec<CheckNotice>;
|
||||||
|
}
|
||||||
|
@ -35,7 +35,9 @@ use crate::model::data_form::DataForm;
|
|||||||
use crate::model::property_catalogue::PropertyCatalogue;
|
use crate::model::property_catalogue::PropertyCatalogue;
|
||||||
use crate::model::requirements::Requires;
|
use crate::model::requirements::Requires;
|
||||||
use crate::model::unterformular::Unterformular;
|
use crate::model::unterformular::Unterformular;
|
||||||
use crate::model::{Comparable, FolderContent, FormEntryContainer, Listable, Sortable};
|
use crate::model::{
|
||||||
|
CheckNotice, Checkable, Comparable, FolderContent, FormEntryContainer, Listable, Sortable,
|
||||||
|
};
|
||||||
use crate::profile::Profile;
|
use crate::profile::Profile;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
@ -409,6 +411,12 @@ impl FromStr for OnkostarEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Checkable for OnkostarEditor {
|
||||||
|
fn check(&self) -> Vec<CheckNotice> {
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct InfoXML {
|
pub struct InfoXML {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user