diff --git a/Cargo.lock b/Cargo.lock index 3aa631c..9d60ca5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -462,12 +462,6 @@ dependencies = [ "rustc_version", ] -[[package]] -name = "exitcode" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193" - [[package]] name = "fastrand" version = "1.8.0" @@ -499,7 +493,6 @@ dependencies = [ "clap-verbosity-flag", "criterion", "error-stack", - "exitcode", "goldenfile", "itoa-const", "log", @@ -515,6 +508,7 @@ dependencies = [ "rustdoc-json", "seahash", "simple_logger", + "sysexits", "tempfile", "thiserror", "tokio", @@ -1383,6 +1377,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sysexits" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1569182c734bec75e863247ebbc4423493a46525314245426f48082e72674a0" + [[package]] name = "tempfile" version = "3.3.0" diff --git a/Cargo.toml b/Cargo.toml index ac95705..d2ed4af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ clap = { version = "4.0.9", features = ["derive", "wrap_help"] } clap-num = "1.0.0" clap-verbosity-flag = "2.0.0" error-stack = "0.2.1" -exitcode = "1.1.2" # TODO use the real itoa once https://github.com/dtolnay/itoa/pull/34 goes through itoa-const = "1.0.1" log = { version = "0.4.17", features = ["release_max_level_info"] } @@ -25,6 +24,7 @@ rand = { version = "0.8.5", default-features = false } rand_distr = "0.4.3" rand_xoshiro = "0.6.0" simple_logger = { version = "2.3.0", default-features = false, features = ["colors"] } +sysexits = "0.3.2" thiserror = "1.0.37" tokio = { version = "1.21.2", features = ["rt"] } tracing = { version = "0.1.36", features = ["release_max_level_off", "log"] } diff --git a/src/core/scheduler.rs b/src/core/scheduler.rs index 05af09f..bf0cc8d 100644 --- a/src/core/scheduler.rs +++ b/src/core/scheduler.rs @@ -52,9 +52,9 @@ pub async fn run( .await .into_report() .change_context(Error::TaskJoin) - .attach(ExitCode::from(u8::try_from(exitcode::SOFTWARE).unwrap()))? + .attach(ExitCode::from(sysexits::ExitCode::Software))? .change_context(Error::Io) - .attach(ExitCode::from(u8::try_from(exitcode::IOERR).unwrap()))?; + .attach(ExitCode::from(sysexits::ExitCode::IoErr))?; #[cfg(dry_run)] let outcome = task; diff --git a/src/generator.rs b/src/generator.rs index b0bae9a..109a0b0 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -5,8 +5,8 @@ )] use std::{ - cmp::max, fs::create_dir_all, io::Write, num::NonZeroUsize, path::PathBuf, - process::ExitCode, thread, + cmp::max, fs::create_dir_all, io::Write, num::NonZeroUsize, path::PathBuf, process::ExitCode, + thread, }; use error_stack::{IntoReport, Report, Result, ResultExt}; @@ -169,14 +169,14 @@ fn validated_options(generator: Generator) -> Result { .into_report() .attach_printable_lazy(|| format!("Failed to create directory {:?}", generator.root_dir)) .change_context(Error::InvalidEnvironment) - .attach(ExitCode::from(u8::try_from(exitcode::IOERR).unwrap()))?; + .attach(ExitCode::from(sysexits::ExitCode::IoErr))?; if generator .root_dir .read_dir() .into_report() .attach_printable_lazy(|| format!("Failed to read directory {:?}", generator.root_dir)) .change_context(Error::InvalidEnvironment) - .attach(ExitCode::from(u8::try_from(exitcode::IOERR).unwrap()))? + .attach(ExitCode::from(sysexits::ExitCode::IoErr))? .count() != 0 { @@ -185,7 +185,7 @@ fn validated_options(generator: Generator) -> Result { "The root directory {:?} must be empty.", generator.root_dir )) - .attach(ExitCode::from(u8::try_from(exitcode::DATAERR).unwrap())); + .attach(ExitCode::from(sysexits::ExitCode::DataErr)); } let num_files = generator.num_files_with_ratio.num_files.get() as f64; @@ -323,7 +323,7 @@ fn run_generator(config: Configuration) -> Result { .build() .into_report() .change_context(Error::RuntimeCreation) - .attach(ExitCode::from(u8::try_from(exitcode::OSERR).unwrap()))?; + .attach(ExitCode::from(sysexits::ExitCode::OsErr))?; event!(Level::INFO, config = ?config, "Starting config"); runtime.block_on(run_generator_async(config, parallelism))