From 838479f86a2ee335e4d9a6dffe8f603b39785fe5 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 29 Sep 2022 19:03:03 +0200 Subject: [PATCH] link: update to clap 4 --- src/uu/link/Cargo.toml | 2 +- src/uu/link/src/link.rs | 6 ++---- tests/by-util/test_link.rs | 12 ++++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/uu/link/Cargo.toml b/src/uu/link/Cargo.toml index 958adc998..6b4e218da 100644 --- a/src/uu/link/Cargo.toml +++ b/src/uu/link/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" path = "src/link.rs" [dependencies] -clap = { version = "3.2", features = ["wrap_help", "cargo"] } +clap = { version = "4.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.16", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index ba754007f..80b2b1f9b 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -35,7 +35,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote())) } -pub fn uu_app<'a>() -> Command<'a> { +pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) @@ -45,9 +45,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(options::FILES) .hide(true) .required(true) - .min_values(2) - .max_values(2) - .takes_value(true) + .num_args(2) .value_hint(clap::ValueHint::AnyPath) .value_parser(ValueParser::os_string()), ) diff --git a/tests/by-util/test_link.rs b/tests/by-util/test_link.rs index a1f4f2c3f..c65dc29d8 100644 --- a/tests/by-util/test_link.rs +++ b/tests/by-util/test_link.rs @@ -50,9 +50,9 @@ fn test_link_nonexistent_file() { fn test_link_one_argument() { let (_, mut ucmd) = at_and_ucmd!(); let file = "test_link_argument"; - ucmd.args(&[file]).fails().stderr_contains( - "error: The argument '...' requires at least 2 values but only 1 was provided", - ); + ucmd.args(&[file]) + .fails() + .stderr_contains("requires 2 values"); } #[test] @@ -63,7 +63,7 @@ fn test_link_three_arguments() { "test_link_argument2", "test_link_argument3", ]; - ucmd.args(&arguments[..]).fails().stderr_contains( - format!("error: The value '{}' was provided to '...' but it wasn't expecting any more values", arguments[2]), - ); + ucmd.args(&arguments[..]) + .fails() + .stderr_contains("requires 2 values"); }