mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-04-19 19:56:50 +00:00
Issue #15: Show list of available checks
This commit is contained in:
parent
e2d5eedd02
commit
6da1c48c28
@ -112,3 +112,49 @@ pub trait Checkable {
|
|||||||
pub trait Fixable {
|
pub trait Fixable {
|
||||||
fn fix(&mut self) -> bool;
|
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))
|
||||||
|
}
|
||||||
|
11
src/cli.rs
11
src/cli.rs
@ -101,8 +101,15 @@ 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")]
|
#[command(about = "Überprüfe OSC-Datei auf bekannte Problemen")]
|
||||||
Check { file: String },
|
Check {
|
||||||
|
file: String,
|
||||||
|
#[arg(
|
||||||
|
long = "list",
|
||||||
|
help = "Prüfe nicht und zeige Liste mit Checks auf bekannte Problemen"
|
||||||
|
)]
|
||||||
|
list: bool,
|
||||||
|
},
|
||||||
#[cfg(feature = "unzip-osb")]
|
#[cfg(feature = "unzip-osb")]
|
||||||
#[command(about = "Entpackt eine OSB-Datei")]
|
#[command(about = "Entpackt eine OSB-Datei")]
|
||||||
UnzipOsb {
|
UnzipOsb {
|
||||||
|
@ -32,6 +32,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::checks::osc::check;
|
use crate::checks::osc::check;
|
||||||
|
use crate::checks::print_checks;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use console::style;
|
use console::style;
|
||||||
use dialoguer::Confirm;
|
use dialoguer::Confirm;
|
||||||
@ -259,11 +260,15 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
SubCommand::Check { file } => {
|
SubCommand::Check { file, list } => {
|
||||||
|
if list {
|
||||||
|
print_checks();
|
||||||
|
} else {
|
||||||
check(Path::new(file.as_str()))
|
check(Path::new(file.as_str()))
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|check_notice| println!("{}", check_notice));
|
.for_each(|check_notice| println!("{}", check_notice));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#[cfg(feature = "unzip-osb")]
|
#[cfg(feature = "unzip-osb")]
|
||||||
SubCommand::UnzipOsb {
|
SubCommand::UnzipOsb {
|
||||||
file,
|
file,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user