link: update to clap 4

This commit is contained in:
Terts Diepraam 2022-09-29 19:03:03 +02:00
parent 6eb7c64f7a
commit 838479f86a
3 changed files with 9 additions and 11 deletions

View file

@ -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]]

View file

@ -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()),
)

View file

@ -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 '<FILES>...' 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 '<FILES>...' but it wasn't expecting any more values", arguments[2]),
);
ucmd.args(&arguments[..])
.fails()
.stderr_contains("requires 2 values");
}