1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge pull request #5561 from tertsdiepraam/fixup-macros

all: reduce imports needed for `show` and `show_if_err` macros
This commit is contained in:
Sylvestre Ledru 2023-11-29 15:10:59 +01:00 committed by GitHub
commit 3cadeb734d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 15 additions and 14 deletions

View file

@ -17,7 +17,7 @@ use uucore::line_ending::LineEnding;
use self::searcher::Searcher; use self::searcher::Searcher;
use matcher::{ExactMatcher, Matcher, WhitespaceMatcher}; use matcher::{ExactMatcher, Matcher, WhitespaceMatcher};
use uucore::ranges::Range; use uucore::ranges::Range;
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_if_err}; use uucore::{format_usage, help_about, help_section, help_usage, show_error, show_if_err};
mod matcher; mod matcher;
mod searcher; mod searcher;

View file

@ -50,9 +50,9 @@ use uucore::display::Quotable;
#[cfg(unix)] #[cfg(unix)]
use uucore::error::set_exit_code; use uucore::error::set_exit_code;
use uucore::error::{FromIo, UResult}; use uucore::error::{FromIo, UResult};
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use uucore::{show, show_if_err}; use uucore::show_if_err;
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
const ABOUT: &str = help_about!("dd.md"); const ABOUT: &str = help_about!("dd.md");
const AFTER_HELP: &str = help_section!("after help", "dd.md"); const AFTER_HELP: &str = help_section!("after help", "dd.md");

View file

@ -9,7 +9,7 @@ use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
use std::ffi::OsString; use std::ffi::OsString;
use std::io::{self, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write}; use std::io::{self, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UError, UResult, USimpleError}; use uucore::error::{FromIo, UResult, USimpleError};
use uucore::line_ending::LineEnding; use uucore::line_ending::LineEnding;
use uucore::lines::lines; use uucore::lines::lines;
use uucore::{format_usage, help_about, help_usage, show}; use uucore::{format_usage, help_about, help_usage, show};

View file

@ -10,7 +10,7 @@ use nix::sys::signal::{self, Signal};
use nix::unistd::Pid; use nix::unistd::Pid;
use std::io::Error; use std::io::Error;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UError, UResult, USimpleError}; use uucore::error::{FromIo, UResult, USimpleError};
use uucore::signals::{signal_by_name_or_value, ALL_SIGNALS}; use uucore::signals::{signal_by_name_or_value, ALL_SIGNALS};
use uucore::{format_usage, help_about, help_usage, show}; use uucore::{format_usage, help_about, help_usage, show};

View file

@ -16,7 +16,7 @@ use uucore::error::{UResult, USimpleError};
#[cfg(not(windows))] #[cfg(not(windows))]
use uucore::mode; use uucore::mode;
use uucore::{display::Quotable, fs::dir_strip_dot_for_creation}; use uucore::{display::Quotable, fs::dir_strip_dot_for_creation};
use uucore::{format_usage, help_about, help_section, help_usage, show, show_if_err}; use uucore::{format_usage, help_about, help_section, help_usage, show_if_err};
static DEFAULT_PERM: u32 = 0o777; static DEFAULT_PERM: u32 = 0o777;

View file

@ -21,7 +21,7 @@ use std::os::windows;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use uucore::backup_control::{self, source_is_target_backup}; use uucore::backup_control::{self, source_is_target_backup};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError, UUsageError}; use uucore::error::{set_exit_code, FromIo, UResult, USimpleError, UUsageError};
use uucore::fs::{are_hardlinks_or_one_way_symlink_to_same_file, are_hardlinks_to_same_file}; use uucore::fs::{are_hardlinks_or_one_way_symlink_to_same_file, are_hardlinks_to_same_file};
use uucore::update_control; use uucore::update_control;
// These are exposed for projects (e.g. nushell) that want to create an `Options` value, which // These are exposed for projects (e.g. nushell) that want to create an `Options` value, which

View file

@ -13,7 +13,7 @@ use std::str::FromStr;
use units::{IEC_BASES, SI_BASES}; use units::{IEC_BASES, SI_BASES};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UError, UResult}; use uucore::error::UResult;
use uucore::ranges::Range; use uucore::ranges::Range;
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error}; use uucore::{format_usage, help_about, help_section, help_usage, show, show_error};

View file

@ -15,13 +15,13 @@ use std::{
use uucore::fs::make_path_relative_to; use uucore::fs::make_path_relative_to;
use uucore::{ use uucore::{
display::{print_verbatim, Quotable}, display::{print_verbatim, Quotable},
error::{FromIo, UResult}, error::{FromIo, UClapError, UResult},
format_usage, format_usage,
fs::{canonicalize, MissingHandling, ResolveMode}, fs::{canonicalize, MissingHandling, ResolveMode},
help_about, help_usage, help_about, help_usage,
line_ending::LineEnding, line_ending::LineEnding,
show_if_err,
}; };
use uucore::{error::UClapError, show, show_if_err};
static ABOUT: &str = help_about!("realpath.md"); static ABOUT: &str = help_about!("realpath.md");
const USAGE: &str = help_usage!("realpath.md"); const USAGE: &str = help_usage!("realpath.md");

View file

@ -17,7 +17,7 @@ use std::path::{Path, PathBuf};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::parse_size::parse_size_u64; use uucore::parse_size::parse_size_u64;
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_if_err}; use uucore::{format_usage, help_about, help_section, help_usage, show_error, show_if_err};
const ABOUT: &str = help_about!("shred.md"); const ABOUT: &str = help_about!("shred.md");
const USAGE: &str = help_usage!("shred.md"); const USAGE: &str = help_usage!("shred.md");

View file

@ -31,7 +31,7 @@ use std::fs::File;
use std::io::{self, stdin, stdout, BufRead, BufReader, BufWriter, Read, Seek, SeekFrom, Write}; use std::io::{self, stdin, stdout, BufRead, BufReader, BufWriter, Read, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{get_exit_code, set_exit_code, FromIo, UError, UResult, USimpleError}; use uucore::error::{get_exit_code, set_exit_code, FromIo, UResult, USimpleError};
use uucore::{show, show_error}; use uucore::{show, show_error};
#[uucore::main] #[uucore::main]

View file

@ -17,7 +17,7 @@ use std::ffi::OsString;
use std::fs::{self, File}; use std::fs::{self, File};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UError, UResult, USimpleError}; use uucore::error::{FromIo, UResult, USimpleError};
use uucore::{format_usage, help_about, help_usage, show}; use uucore::{format_usage, help_about, help_usage, show};
const ABOUT: &str = help_about!("touch.md"); const ABOUT: &str = help_about!("touch.md");

View file

@ -91,6 +91,7 @@ pub static UTILITY_IS_SECOND_ARG: AtomicBool = AtomicBool::new(false);
#[macro_export] #[macro_export]
macro_rules! show( macro_rules! show(
($err:expr) => ({ ($err:expr) => ({
use $crate::error::UError;
let e = $err; let e = $err;
$crate::error::set_exit_code(e.code()); $crate::error::set_exit_code(e.code());
eprintln!("{}: {}", $crate::util_name(), e); eprintln!("{}: {}", $crate::util_name(), e);
@ -131,7 +132,7 @@ macro_rules! show(
macro_rules! show_if_err( macro_rules! show_if_err(
($res:expr) => ({ ($res:expr) => ({
if let Err(e) = $res { if let Err(e) = $res {
show!(e); $crate::show!(e);
} }
}) })
); );