diff --git a/examples/dd_test.rs b/examples/dd_test.rs index 1ad259f..63fcea3 100644 --- a/examples/dd_test.rs +++ b/examples/dd_test.rs @@ -34,7 +34,7 @@ struct Opt { } #[cmd_lib::main] -fn main() -> MainResult { +fn main() -> CmdResult { let Opt { block_size, thread_num, diff --git a/examples/pipes.rs b/examples/pipes.rs index 0f44de7..4d06fe1 100644 --- a/examples/pipes.rs +++ b/examples/pipes.rs @@ -339,7 +339,7 @@ fn rand() -> i32 { } #[cmd_lib::main] -fn main() -> MainResult { +fn main() -> CmdResult { // simple pre-check of TERM, tput's error message should be enough let term = std::env::var("TERM").unwrap(); run_cmd!(tput -T $term sgr0 >/dev/null)?; diff --git a/examples/rust_cookbook.rs b/examples/rust_cookbook.rs index b7f0fe6..a7d5f54 100644 --- a/examples/rust_cookbook.rs +++ b/examples/rust_cookbook.rs @@ -6,7 +6,7 @@ use cmd_lib::*; use std::io::{BufRead, BufReader}; #[cmd_lib::main] -fn main() -> MainResult { +fn main() -> CmdResult { cmd_lib::set_pipefail(false); // do not fail due to pipe errors // Run an external command and process stdout diff --git a/examples/tetris.rs b/examples/tetris.rs index 7266d9c..0311880 100644 --- a/examples/tetris.rs +++ b/examples/tetris.rs @@ -557,7 +557,7 @@ fn cmd_exit() { } #[cmd_lib::main] -fn main() -> MainResult { +fn main() -> CmdResult { #[rustfmt::skip] let old_cfg = run_fun!(stty -g)?; // let's save terminal state ... tls_set!(old_stty_cfg, |cfg| *cfg = old_cfg); diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 4c4f8f2..a4b10a8 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -8,7 +8,7 @@ use quote::quote; /// # use cmd_lib::*; /// /// #[cmd_lib::main] -/// fn main() -> MainResult { +/// fn main() -> CmdResult { /// run_cmd!(bad_cmd)?; /// Ok(()) /// } diff --git a/src/lib.rs b/src/lib.rs index c101748..46b4254 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -383,9 +383,6 @@ pub use log as inner_log; #[doc(hidden)] pub use logger::try_init_default_logger; #[doc(hidden)] -pub use main_error::MainError; -pub use main_error::MainResult; -#[doc(hidden)] pub use process::{register_cmd, AsOsStr, Cmd, CmdString, Cmds, GroupCmds, Redirect}; pub use process::{set_debug, set_pipefail, CmdEnv}; @@ -393,6 +390,5 @@ mod builtins; mod child; mod io; mod logger; -mod main_error; mod process; mod thread_local; diff --git a/src/main_error.rs b/src/main_error.rs deleted file mode 100644 index 8b5bf9b..0000000 --- a/src/main_error.rs +++ /dev/null @@ -1,28 +0,0 @@ -use std::error::Error; -use std::fmt::{self, Debug, Display}; - -// Modified from https://github.com/danleh/main_error -pub struct MainError(Box); - -impl>> From for MainError { - fn from(e: E) -> Self { - MainError(e.into()) - } -} - -impl Display for MainError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&self.0, f) - } -} - -// Impl Debug (to satisfy trait bound for main()-Result error reporting), but use Display of wrapped -// error internally (for nicer output). -impl Debug for MainError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&self.0, f) - } -} - -/// Convenient type as a shorthand return type for `main()`. -pub type MainResult = Result<(), MainError>;