diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index a81d52ed8..6df240382 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -46,7 +46,7 @@ use std::path::{Path, PathBuf, StripPrefixError}; use std::str::FromStr; use std::string::ToString; use uucore::backup_control::{self, BackupMode}; -use uucore::error::{set_exit_code, ExitCode, UClapError, UError, UResult}; +use uucore::error::{set_exit_code, UClapError, UError, UResult, UUsageError}; use uucore::fs::{canonicalize, is_symlink, MissingHandling, ResolveMode}; use walkdir::WalkDir; @@ -498,8 +498,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let options = Options::from_matches(&matches)?; if options.overwrite == OverwriteMode::NoClobber && options.backup != BackupMode::NoBackup { - show_usage_error!("options --backup and --no-clobber are mutually exclusive"); - return Err(ExitCode(EXIT_ERR).into()); + return Err(UUsageError::new( + EXIT_ERR, + "options --backup and --no-clobber are mutually exclusive", + )); } let paths: Vec = matches diff --git a/src/uucore/src/lib/macros.rs b/src/uucore/src/lib/macros.rs index cdb3affb5..612160e19 100644 --- a/src/uucore/src/lib/macros.rs +++ b/src/uucore/src/lib/macros.rs @@ -25,7 +25,7 @@ //! - Print errors //! - From types implementing [`crate::error::UError`]: [`show!`], //! [`show_if_err!`] -//! - From custom messages: [`show_error!`], [`show_usage_error!`] +//! - From custom messages: [`show_error!`] //! - Print warnings: [`show_warning!`] //! - Terminate util execution //! - Crash program: [`crash!`], [`crash_if_err!`] @@ -155,26 +155,6 @@ macro_rules! show_error( }) ); -/// Show a warning to stderr in a similar style to GNU coreutils. -/// -/// Is this really required? Used in the following locations: -/// -/// ./src/uu/head/src/head.rs:12 -/// ./src/uu/head/src/head.rs:424 -/// ./src/uu/head/src/head.rs:427 -/// ./src/uu/head/src/head.rs:430 -/// ./src/uu/head/src/head.rs:453 -/// ./src/uu/du/src/du.rs:339 -/// ./src/uu/wc/src/wc.rs:270 -/// ./src/uu/wc/src/wc.rs:273 -#[macro_export] -macro_rules! show_error_custom_description ( - ($err:expr,$($args:tt)+) => ({ - eprint!("{}: {}: ", $crate::util_name(), $err); - eprintln!($($args)+); - }) -); - /// Print a warning message to stderr. /// /// Takes [`format!`]-compatible input and prepends it with the current @@ -198,31 +178,6 @@ macro_rules! show_warning( }) ); -/// Show a bad invocation help message in a similar style to GNU coreutils. -/// -/// Takes a [`format!`]-compatible input and prepends it with the current -/// utility's name before printing to stderr. -/// -/// # Examples -/// -/// ``` -/// # #[macro_use] -/// # extern crate uucore; -/// # fn main() { -/// // outputs : Couldn't apply foo to bar -/// // Try ' --help' for more information. -/// show_usage_error!("Couldn't apply {} to {}", "foo", "bar"); -/// # } -/// ``` -#[macro_export] -macro_rules! show_usage_error( - ($($args:tt)+) => ({ - eprint!("{}: ", $crate::util_name()); - eprintln!($($args)+); - eprintln!("Try '{} --help' for more information.", $crate::execution_phrase()); - }) -); - /// Display an error and [`std::process::exit`] /// /// Displays the provided error message using [`show_error!`], then invokes