-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
When one sets the UError usage flag, the error message is appended by:
Try 'util --help' for more information.
But this looks very odd when one starts the utility from somewhere else:
cmp: missing operand after 'cmp'
Try 'Development/diffutils_fork/target/debug/diffutils cmp --help' for more information.
Would it not be better to just output the util name, like:
cmp: missing operand after 'cmp'
Try 'cmp --help' for more information.
This is part of the main macro and could easily be changed:
// disable rust signal handlers (otherwise processes don't dump core after e.g. one SIGSEGV)
#[cfg(all(#signals, unix))]
uucore::disable_rust_signal_handlers().expect("Disabling rust signal handlers failed");
let result = uumain(args);
match result {
Ok(()) => uucore::error::get_exit_code(),
Err(e) => {
let s = format!("{e}");
if s != "" {
uucore::show_error!("{s}");
}
if e.usage() {
use std::io::{stderr, Write as _};
let _ = writeln!(stderr(),"Try '{} --help' for more information.", uucore::execution_phrase());
--> // change: let _ = writeln!(stderr(),"Try '{} --help' for more information.", uucore::util_name());
// or even better to use translate, this makes it also consistent with errors clap returns
--> // let msg_try = uucore::translate!("clap-error-help-suggestion", "command" => uucore::util_name());
// let _ = writeln!(stderr(),"{msg_try}");
}
e.code()
}
}
If it is fine with you I would create the PR to use uucore::util_name() and translate!.
This would result in:
cmp: missing operand after 'cmp'
For more information, try 'cmp --help'.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels