mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +00:00
uucore & cp: remove show_error_custom_description
macros show_usage_error
This commit is contained in:
parent
87e3899477
commit
b983355bc4
2 changed files with 6 additions and 49 deletions
|
@ -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<String> = matches
|
||||
|
|
|
@ -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 <name>: Couldn't apply foo to bar
|
||||
/// // Try '<name> --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
|
||||
|
|
Loading…
Reference in a new issue