mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
uniq: print version and help on stdout again (#6123)
* uniq: print version and help on stdout again * uniq: format test * uniq: replace redundant closure with fn --------- Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
co-authored by
Daniel Hofstetter
parent
e4a1455af5
commit
d060134d97
@@ -518,7 +518,7 @@ fn handle_extract_obs_skip_chars(
|
||||
/// Unfortunately these overrides are necessary, since several GNU tests
|
||||
/// for `uniq` hardcode and require the exact wording of the error message
|
||||
/// and it is not compatible with how Clap formats and displays those error messages.
|
||||
fn map_clap_errors(clap_error: &Error) -> Box<dyn UError> {
|
||||
fn map_clap_errors(clap_error: Error) -> Box<dyn UError> {
|
||||
let footer = "Try 'uniq --help' for more information.";
|
||||
let override_arg_conflict =
|
||||
"--group is mutually exclusive with -c/-d/-D/-u\n".to_string() + footer;
|
||||
@@ -547,7 +547,7 @@ fn map_clap_errors(clap_error: &Error) -> Box<dyn UError> {
|
||||
{
|
||||
override_all_repeated_badoption
|
||||
}
|
||||
_ => clap_error.to_string(),
|
||||
_ => return clap_error.into(),
|
||||
};
|
||||
USimpleError::new(1, error_message)
|
||||
}
|
||||
@@ -558,7 +558,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
|
||||
let matches = uu_app()
|
||||
.try_get_matches_from(args)
|
||||
.map_err(|e| map_clap_errors(&e))?;
|
||||
.map_err(map_clap_errors)?;
|
||||
|
||||
let files = matches.get_many::<OsString>(ARG_FILES);
|
||||
|
||||
|
||||
@@ -18,6 +18,20 @@ fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_help_and_version_on_stdout() {
|
||||
new_ucmd!()
|
||||
.arg("--help")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_contains("Usage");
|
||||
new_ucmd!()
|
||||
.arg("--version")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_contains("uniq");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdin_default() {
|
||||
new_ucmd!()
|
||||
|
||||
Reference in New Issue
Block a user