diff --git a/src/error/format.rs b/src/error/format.rs index 8df011e1..5f5713f4 100644 --- a/src/error/format.rs +++ b/src/error/format.rs @@ -43,43 +43,6 @@ impl ErrorFormatter for KindFormatter { } } -/// Dump the error context reported -#[non_exhaustive] -#[cfg(feature = "error-context")] -pub struct RawFormatter; - -#[cfg(feature = "error-context")] -impl ErrorFormatter for RawFormatter { - fn format_error(error: &crate::error::Error) -> StyledStr { - let mut styled = StyledStr::new(); - start_error(&mut styled); - if let Some(msg) = error.kind().as_str() { - styled.none(msg.to_owned()); - } else if let Some(source) = error.inner.source.as_ref() { - styled.none(source.to_string()); - } else { - styled.none("Unknown cause"); - } - styled.none("\n"); - - if error.context().next().is_some() { - styled.none("\n"); - } - for (kind, value) in error.context() { - if let Some(kind) = kind.as_str() { - styled.none(kind); - styled.none(": "); - styled.none(value.to_string()); - } else { - styled.none(value.to_string()); - } - styled.none("\n"); - } - - styled - } -} - /// Richly formatted error context #[non_exhaustive] #[cfg(feature = "error-context")] diff --git a/src/error/mod.rs b/src/error/mod.rs index b27486b7..181fd68a 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -39,8 +39,6 @@ pub use context::ContextKind; #[cfg(feature = "error-context")] pub use context::ContextValue; #[cfg(feature = "error-context")] -pub use format::RawFormatter; -#[cfg(feature = "error-context")] pub use format::RichFormatter; #[cfg(not(feature = "error-context"))] diff --git a/tests/builder/error.rs b/tests/builder/error.rs index dcd62c24..f927955f 100644 --- a/tests/builder/error.rs +++ b/tests/builder/error.rs @@ -96,25 +96,6 @@ Options: assert_error(err, expected_kind, MESSAGE, false); } -#[test] -#[cfg(feature = "error-context")] -fn raw_prints_help() { - let cmd = Command::new("test"); - let res = cmd - .try_get_matches_from(["test", "--help"]) - .map_err(|e| e.apply::()); - assert!(res.is_err()); - let err = res.unwrap_err(); - let expected_kind = ErrorKind::DisplayHelp; - static MESSAGE: &str = "\ -Usage: test - -Options: - -h, --help Print help information -"; - assert_error(err, expected_kind, MESSAGE, false); -} - #[test] fn kind_formats_validation_error() { let cmd = Command::new("test"); @@ -147,22 +128,3 @@ For more information try '--help' "; assert_error(err, expected_kind, MESSAGE, true); } - -#[test] -#[cfg(feature = "error-context")] -fn raw_formats_validation_error() { - let cmd = Command::new("test"); - let res = cmd - .try_get_matches_from(["test", "unused"]) - .map_err(|e| e.apply::()); - assert!(res.is_err()); - let err = res.unwrap_err(); - let expected_kind = ErrorKind::UnknownArgument; - static MESSAGE: &str = "\ -error: Found an argument which wasn't expected or isn't valid in this context - -Invalid Argument: unused -Usage: test -"; - assert_error(err, expected_kind, MESSAGE, true); -}