diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-08-01 23:45:53 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-08-01 23:45:53 +0200 |
commit | 35ee03cef2d78908e7d6771eb2735a93e4358a60 (patch) | |
tree | 05dc466a2b46bac76a80bb3865b4e9827b231388 /src | |
parent | 8ec5d631f21c54c9bb0bbd7d6fa39513c9242219 (diff) |
Use my new “proxit” crate
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 10 | ||||
-rw-r--r-- | src/main_result.rs | 32 |
2 files changed, 6 insertions, 36 deletions
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<Result<(), Error>> for MainResult { - fn from(r: Result<(), Error>) -> Self { - match r { - Ok(()) => Self::Success, - Err(e) => Self::Failure(e), - } - } -} |