diff --git a/src/checks/mod.rs b/src/checks/mod.rs index bf2396a..c1c9218 100644 --- a/src/checks/mod.rs +++ b/src/checks/mod.rs @@ -112,3 +112,49 @@ pub trait Checkable { pub trait Fixable { fn fix(&mut self) -> bool; } + +pub fn print_checks() { + println!( + "{}", + style("Die folgenden Probleme sind bekannt\n") + .yellow() + .bold() + ); + + struct Problem<'a> { + code: &'a str, + name: &'a str, + description: &'a str, + fixable: bool, + } + + impl<'a> Display for Problem<'a> { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{} {} {}\n\n{}", + style(self.code).bold(), + style(self.name).underlined(), + match self.fixable { + true => style("(Behebbar)").green(), + false => style("(Nicht behebbar)").red(), + }, + self.description + ) + } + } + + vec![Problem { + code: "2023-0001", + name: "Leerzeichen am Ende der Plausibilitätsregel-Bezeichnung (OSTARSUPP-13334)", + description: "Treten Leerzeichen am Ende der Plausibilitätsregel-Bezeichnung auf,\n\ + führt dies zu Fehlern beim Import der OSC-Datei.\n\ + \n\ + Das Problem wird beim Verwenden des Unterbefehls 'modify' automatisch\n\ + behoben und Leerzeichen entfernt. + ", + fixable: true, + }] + .iter() + .for_each(|problem| println!("{}\n", problem)) +} diff --git a/src/cli.rs b/src/cli.rs index d258298..5cb4e99 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -101,8 +101,15 @@ pub enum SubCommand { #[arg(long = "strict", help = "Strikter Vergleich des Inhalts")] strict: bool, }, - #[command(about = "Überprüfe OSC-Datei auf bekannte Fehler")] - Check { file: String }, + #[command(about = "Überprüfe OSC-Datei auf bekannte Problemen")] + Check { + file: String, + #[arg( + long = "list", + help = "Prüfe nicht und zeige Liste mit Checks auf bekannte Problemen" + )] + list: bool, + }, #[cfg(feature = "unzip-osb")] #[command(about = "Entpackt eine OSB-Datei")] UnzipOsb { diff --git a/src/main.rs b/src/main.rs index 88cbf8e..034c12a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use crate::checks::osc::check; +use crate::checks::print_checks; use clap::Parser; use console::style; use dialoguer::Confirm; @@ -259,10 +260,14 @@ fn main() -> Result<(), Box> { } }; } - SubCommand::Check { file } => { - check(Path::new(file.as_str())) - .iter() - .for_each(|check_notice| println!("{}", check_notice)); + SubCommand::Check { file, list } => { + if list { + print_checks(); + } else { + check(Path::new(file.as_str())) + .iter() + .for_each(|check_notice| println!("{}", check_notice)); + } } #[cfg(feature = "unzip-osb")] SubCommand::UnzipOsb {