switch to color_eyre

This commit is contained in:
2025-07-25 19:24:50 +08:00
parent ad98236e06
commit 817db15340
3 changed files with 170 additions and 8 deletions

165
Cargo.lock generated
View File

@@ -2,6 +2,15 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 4 version = 4
[[package]]
name = "addr2line"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
dependencies = [
"gimli",
]
[[package]] [[package]]
name = "adler2" name = "adler2"
version = "2.0.0" version = "2.0.0"
@@ -14,6 +23,21 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "backtrace"
version = "0.3.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
dependencies = [
"addr2line",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
"windows-targets",
]
[[package]] [[package]]
name = "better_default" name = "better_default"
version = "1.0.5" version = "1.0.5"
@@ -60,6 +84,33 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "color-eyre"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d"
dependencies = [
"backtrace",
"color-spantrace",
"eyre",
"indenter",
"once_cell",
"owo-colors",
"tracing-error",
]
[[package]]
name = "color-spantrace"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427"
dependencies = [
"once_cell",
"owo-colors",
"tracing-core",
"tracing-error",
]
[[package]] [[package]]
name = "colored" name = "colored"
version = "3.0.0" version = "3.0.0"
@@ -214,6 +265,12 @@ dependencies = [
"wasi", "wasi",
] ]
[[package]]
name = "gimli"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.15.2" version = "0.15.2"
@@ -274,6 +331,12 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.171" version = "0.2.171"
@@ -302,13 +365,19 @@ version = "0.4.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
[[package]]
name = "memchr"
version = "2.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
[[package]] [[package]]
name = "mhws-tex-decompressor" name = "mhws-tex-decompressor"
version = "0.1.3" version = "0.1.3"
dependencies = [ dependencies = [
"color-eyre",
"colored", "colored",
"dialoguer", "dialoguer",
"eyre",
"indicatif", "indicatif",
"parking_lot", "parking_lot",
"rayon", "rayon",
@@ -416,12 +485,27 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
[[package]]
name = "object"
version = "0.36.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.21.1" version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
[[package]]
name = "owo-colors"
version = "4.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e"
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.12.3" version = "0.12.3"
@@ -445,6 +529,12 @@ dependencies = [
"windows-targets", "windows-targets",
] ]
[[package]]
name = "pin-project-lite"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.32" version = "0.3.32"
@@ -523,7 +613,7 @@ dependencies = [
[[package]] [[package]]
name = "ree-pak-core" name = "ree-pak-core"
version = "0.4.0" version = "0.4.1"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"byteorder", "byteorder",
@@ -540,6 +630,12 @@ dependencies = [
"zstd", "zstd",
] ]
[[package]]
name = "rustc-demangle"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
[[package]] [[package]]
name = "rustc-hash" name = "rustc-hash"
version = "2.1.1" version = "2.1.1"
@@ -591,6 +687,15 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "shell-words" name = "shell-words"
version = "1.1.0" version = "1.1.0"
@@ -695,6 +800,56 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "thread_local"
version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185"
dependencies = [
"cfg-if",
]
[[package]]
name = "tracing"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
dependencies = [
"pin-project-lite",
"tracing-core",
]
[[package]]
name = "tracing-core"
version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-error"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db"
dependencies = [
"tracing",
"tracing-subscriber",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
dependencies = [
"sharded-slab",
"thread_local",
"tracing-core",
]
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.18" version = "1.0.18"
@@ -707,6 +862,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
[[package]]
name = "valuable"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.14.2+wasi-0.2.4" version = "0.14.2+wasi-0.2.4"

View File

@@ -12,7 +12,7 @@ ree-pak-core = { path = "../../ree-pak-rs/ree-pak-core" }
# ree-pak-core = { git = "https://github.com/eigeen/ree-pak-rs.git", branch = "main" } # ree-pak-core = { git = "https://github.com/eigeen/ree-pak-rs.git", branch = "main" }
dialoguer = "0.11" dialoguer = "0.11"
eyre = "0.6" color-eyre = "0.6.5"
indicatif = "0.17" indicatif = "0.17"
rayon = "1.10" rayon = "1.10"
parking_lot = "0.12" parking_lot = "0.12"

View File

@@ -9,6 +9,7 @@ use std::{
time::Duration, time::Duration,
}; };
use color_eyre::eyre::bail;
use colored::Colorize; use colored::Colorize;
use dialoguer::{Input, Select, theme::ColorfulTheme}; use dialoguer::{Input, Select, theme::ColorfulTheme};
use indicatif::{HumanBytes, ProgressBar, ProgressStyle}; use indicatif::{HumanBytes, ProgressBar, ProgressStyle};
@@ -30,7 +31,7 @@ fn main() {
println!("Version v{} - Tool by @Eigeen", env!("CARGO_PKG_VERSION")); println!("Version v{} - Tool by @Eigeen", env!("CARGO_PKG_VERSION"));
if let Err(e) = main_entry() { if let Err(e) = main_entry() {
eprintln!("{}: {}", "Error".red().bold(), e); eprintln!("{}: {:#}", "Error".red().bold(), e);
wait_for_exit(); wait_for_exit();
std::process::exit(1); std::process::exit(1);
} }
@@ -43,7 +44,7 @@ fn panic_hook(info: &std::panic::PanicHookInfo) {
std::process::exit(1); std::process::exit(1);
} }
fn main_entry() -> eyre::Result<()> { fn main_entry() -> color_eyre::Result<()> {
let input: String = Input::with_theme(&ColorfulTheme::default()) let input: String = Input::with_theme(&ColorfulTheme::default())
.show_default(true) .show_default(true)
.default("re_chunk_000.pak.sub_000.pak".to_string()) .default("re_chunk_000.pak.sub_000.pak".to_string())
@@ -55,7 +56,7 @@ fn main_entry() -> eyre::Result<()> {
let input_path = Path::new(&input); let input_path = Path::new(&input);
if !input_path.is_file() { if !input_path.is_file() {
eyre::bail!("input file not exists."); bail!("input file not exists.");
} }
const FALSE_TRUE_SELECTION: [&str; 2] = ["False", "True"]; const FALSE_TRUE_SELECTION: [&str; 2] = ["False", "True"];
@@ -121,7 +122,7 @@ fn main_entry() -> eyre::Result<()> {
let bytes_written = AtomicUsize::new(0); let bytes_written = AtomicUsize::new(0);
let err = entries let err = entries
.par_iter() .par_iter()
.try_for_each(move |&entry| -> eyre::Result<()> { .try_for_each(move |&entry| -> color_eyre::Result<()> {
let pak_writer_mtx = &pak_writer_mtx1; let pak_writer_mtx = &pak_writer_mtx1;
let bar = &bar1; let bar = &bar1;
// read raw tex file // read raw tex file
@@ -206,7 +207,7 @@ fn write_to_pak<W>(
file_name: impl FileNameExt, file_name: impl FileNameExt,
data: &[u8], data: &[u8],
use_feature_clone: bool, use_feature_clone: bool,
) -> eyre::Result<usize> ) -> color_eyre::Result<usize>
where where
W: io::Write + io::Seek, W: io::Write + io::Seek,
{ {