From 812f2db464a5ff2d0c33dbe84c63c95807fba0f7 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 11 Jan 2022 13:25:47 +0100 Subject: [PATCH] echo: clap 3 --- src/uu/echo/Cargo.toml | 2 +- src/uu/echo/src/echo.rs | 33 +++++++++++++-------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/uu/echo/Cargo.toml b/src/uu/echo/Cargo.toml index 05dd1eba1..e316bbaa4 100644 --- a/src/uu/echo/Cargo.toml +++ b/src/uu/echo/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/echo.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.10", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index a0e6c0d9c..5eda9d5b1 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -128,44 +128,37 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { execute(no_newline, escaped, values).map_err_context(|| "could not write to stdout".to_string()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) // TrailingVarArg specifies the final positional argument is a VarArg // and it doesn't attempts the parse any further args. // Final argument must have multiple(true) or the usage string equivalent. .setting(clap::AppSettings::TrailingVarArg) - .setting(clap::AppSettings::AllowLeadingHyphen) + .setting(clap::AppSettings::AllowHyphenValues) .version(crate_version!()) .about(SUMMARY) .after_help(AFTER_HELP) - .usage(USAGE) + .override_usage(USAGE) .arg( - Arg::with_name(options::NO_NEWLINE) - .short("n") + Arg::new(options::NO_NEWLINE) + .short('n') .help("do not output the trailing newline") - .takes_value(false) - .display_order(1), + .takes_value(false), ) .arg( - Arg::with_name(options::ENABLE_BACKSLASH_ESCAPE) - .short("e") + Arg::new(options::ENABLE_BACKSLASH_ESCAPE) + .short('e') .help("enable interpretation of backslash escapes") - .takes_value(false) - .display_order(2), + .takes_value(false), ) .arg( - Arg::with_name(options::DISABLE_BACKSLASH_ESCAPE) - .short("E") + Arg::new(options::DISABLE_BACKSLASH_ESCAPE) + .short('E') .help("disable interpretation of backslash escapes (default)") - .takes_value(false) - .display_order(3), - ) - .arg( - Arg::with_name(options::STRING) - .multiple(true) - .allow_hyphen_values(true), + .takes_value(false), ) + .arg(Arg::new(options::STRING).multiple_occurrences(true)) } fn execute(no_newline: bool, escaped: bool, free: Vec) -> io::Result<()> {