Mirror von
https://github.com/Chaoscaot/schemsearch
synchronisiert 2024-11-19 10:20:08 +01:00
Add Progressbar
Dieser Commit ist enthalten in:
Ursprung
3792be48a3
Commit
916613773b
@ -15,6 +15,7 @@ clap = { version = "4.1.8", features = ["cargo"] }
|
||||
futures = { version = "0.3", optional = true }
|
||||
sqlx = { version = "0.6", features = [ "runtime-async-std-native-tls" , "mysql" ], optional = true }
|
||||
rayon = "1.7.0"
|
||||
indicatif = { version = "0.17.3", features = ["rayon"] }
|
||||
|
||||
[features]
|
||||
sql = ["dep:schemsearch-sql", "dep:futures", "dep:sqlx"]
|
||||
|
@ -36,6 +36,7 @@ use schemsearch_sql::filter::SchematicFilter;
|
||||
use schemsearch_sql::load_all_schematics;
|
||||
#[cfg(feature = "sql")]
|
||||
use crate::types::SqlSchematicSupplier;
|
||||
use indicatif::{ProgressBar, ParallelProgressIterator, ProgressStyle};
|
||||
|
||||
fn main() {
|
||||
#[allow(unused_mut)]
|
||||
@ -256,7 +257,7 @@ fn main() {
|
||||
}
|
||||
ThreadPoolBuilder::new().num_threads(*matches.get_one::<usize>("threads").expect("Could not get threads")).build_global().unwrap();
|
||||
|
||||
let matches: Vec<Result> = schematics.par_iter().map(|schem| {
|
||||
let matches: Vec<Result> = schematics.par_iter().progress_with_style(ProgressStyle::default_bar()).map(|schem| {
|
||||
match schem {
|
||||
SchematicSupplierType::PATH(schem) => {
|
||||
let schematic = match load_schem(&schem.path) {
|
||||
|
@ -120,14 +120,14 @@ pub fn parse_schematic(data: &Vec<u8>) -> Schematic {
|
||||
#[allow(unused_imports)]
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
use schemsearch_files::Schematic;
|
||||
use crate::pattern_mapper::strip_data;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn read_schematic() {
|
||||
let schematic = Schematic::load(Path::new("../tests/simple.schem")).unwrap();
|
||||
let schematic = Schematic::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||
assert_eq!(schematic.width as usize * schematic.height as usize * schematic.length as usize, schematic.block_data.len());
|
||||
assert_eq!(schematic.palette_max, schematic.palette.len() as i32);
|
||||
}
|
||||
@ -142,7 +142,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_strip_schem() {
|
||||
let schematic = Schematic::load(Path::new("../tests/simple.schem")).unwrap();
|
||||
let schematic = Schematic::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||
let stripped = strip_data(&schematic);
|
||||
|
||||
assert_eq!(stripped.palette.keys().any(|k| k.contains('[')), false);
|
||||
@ -150,24 +150,24 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_match_palette() {
|
||||
let schematic = Schematic::load(Path::new("../tests/simple.schem")).unwrap();
|
||||
let endstone = Schematic::load(Path::new("../tests/endstone.schem")).unwrap();
|
||||
let schematic = Schematic::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||
let endstone = Schematic::load(&PathBuf::from("../tests/endstone.schem")).unwrap();
|
||||
|
||||
let _ = match_palette(&schematic, &endstone, true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match_palette_ignore_data() {
|
||||
let schematic = Schematic::load(Path::new("../tests/simple.schem")).unwrap();
|
||||
let endstone = Schematic::load(Path::new("../tests/endstone.schem")).unwrap();
|
||||
let schematic = Schematic::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||
let endstone = Schematic::load(&PathBuf::from("../tests/endstone.schem")).unwrap();
|
||||
|
||||
let _ = match_palette(&schematic, &endstone, false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_big_search() {
|
||||
let schematic = Schematic::load(Path::new("../tests/simple.schem")).unwrap();
|
||||
let endstone = Schematic::load(Path::new("../tests/endstone.schem")).unwrap();
|
||||
let schematic = Schematic::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||
let endstone = Schematic::load(&PathBuf::from("../tests/endstone.schem")).unwrap();
|
||||
|
||||
let _ = search(schematic, &endstone, SearchBehavior {
|
||||
ignore_block_data: true,
|
||||
@ -181,8 +181,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
pub fn test_search() {
|
||||
let schematic = Schematic::load(Path::new("../tests/Random.schem")).unwrap();
|
||||
let pattern = Schematic::load(Path::new("../tests/Pattern.schem")).unwrap();
|
||||
let schematic = Schematic::load(&PathBuf::from("../tests/Random.schem")).unwrap();
|
||||
let pattern = Schematic::load(&PathBuf::from("../tests/Pattern.schem")).unwrap();
|
||||
|
||||
let matches = search(schematic, &pattern, SearchBehavior {
|
||||
ignore_block_data: true,
|
||||
@ -200,8 +200,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
pub fn test_search_ws() {
|
||||
let schematic = Schematic::load(Path::new("../tests/warships/GreyFly-by-Bosslar.schem")).unwrap();
|
||||
let pattern = Schematic::load(Path::new("../tests/gray_castle_complex.schem")).unwrap();
|
||||
let schematic = Schematic::load(&PathBuf::from("../tests/warships/GreyFly-by-Bosslar.schem")).unwrap();
|
||||
let pattern = Schematic::load(&PathBuf::from("../tests/gray_castle_complex.schem")).unwrap();
|
||||
|
||||
let matches = search(schematic, &pattern, SearchBehavior {
|
||||
ignore_block_data: false,
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren