Merge pull request #4828 from cakebaker/cp_fix_help_output

cp: fix "after help" output
This commit is contained in:
Sylvestre Ledru 2023-05-05 22:21:26 +02:00 committed by GitHub
commit ea26719e9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -299,7 +299,10 @@ pub fn uu_app() -> Command {
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.after_help(AFTER_HELP) .after_help(format!(
"{AFTER_HELP}\n\n{}",
backup_control::BACKUP_CONTROL_LONG_HELP
))
.infer_long_args(true) .infer_long_args(true)
.arg( .arg(
Arg::new(options::TARGET_DIRECTORY) Arg::new(options::TARGET_DIRECTORY)
@ -561,13 +564,11 @@ pub fn uu_app() -> Command {
#[uucore::main] #[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app() let matches = uu_app().try_get_matches_from(args);
.after_help(backup_control::BACKUP_CONTROL_LONG_HELP)
.try_get_matches_from(args);
// The error is parsed here because we do not want version or help being printed to stderr. // The error is parsed here because we do not want version or help being printed to stderr.
if let Err(e) = matches { if let Err(e) = matches {
let mut app = uu_app().after_help(backup_control::BACKUP_CONTROL_LONG_HELP); let mut app = uu_app();
match e.kind() { match e.kind() {
clap::error::ErrorKind::DisplayHelp => { clap::error::ErrorKind::DisplayHelp => {