From 35ee03cef2d78908e7d6771eb2735a93e4358a60 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 1 Aug 2023 23:45:53 +0200 Subject: Use my new “proxit” crate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/main.rs | 10 ++++++---- src/main_result.rs | 32 -------------------------------- 4 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 src/main_result.rs diff --git a/Cargo.lock b/Cargo.lock index dd0880f..525871d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,9 +76,16 @@ name = "mmv" version = "0.1.0" dependencies = [ "lexopt", + "proxit", "tempfile", ] +[[package]] +name = "proxit" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799e1d32ce9ca2aabd2ae1806c7673f2ec583b9260415f3416538865dacd2f70" + [[package]] name = "redox_syscall" version = "0.3.5" diff --git a/Cargo.toml b/Cargo.toml index 55763a3..810f69d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,5 @@ authors = [ [dependencies] lexopt = "0.1.0" +proxit = "1.0.1" tempfile = "3.7.0" diff --git a/src/main.rs b/src/main.rs index 1698968..383175d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ mod error; -mod main_result; use std::{ cmp::Reverse, @@ -14,9 +13,12 @@ use std::{ process::{Command, Stdio}, }; -use tempfile::tempdir; +use { + proxit::MainResult, + tempfile::tempdir, +}; -use {error::Error, main_result::MainResult}; +use error::Error; #[derive(Default)] struct Flags { @@ -27,7 +29,7 @@ struct Flags { pub verbose: bool, } -fn main() -> MainResult { +fn main() -> MainResult<(), Error> { work().into() } diff --git a/src/main_result.rs b/src/main_result.rs deleted file mode 100644 index 36e3096..0000000 --- a/src/main_result.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::{ - io::{self, Write}, - process::{ExitCode, Termination}, -}; - -use super::error::Error; - -pub enum MainResult { - Success, - Failure(Error), -} - -impl Termination for MainResult { - fn report(self) -> ExitCode { - match self { - Self::Success => ExitCode::SUCCESS, - Self::Failure(e) => { - let _ = write!(io::stderr(), "{e}"); - ExitCode::FAILURE - } - } - } -} - -impl From> for MainResult { - fn from(r: Result<(), Error>) -> Self { - match r { - Ok(()) => Self::Success, - Err(e) => Self::Failure(e), - } - } -} -- cgit v1.2.3