mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
link: update to clap 4
This commit is contained in:
parent
6eb7c64f7a
commit
838479f86a
3 changed files with 9 additions and 11 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/link.rs"
|
path = "src/link.rs"
|
||||||
|
|
||||||
[dependencies]
|
[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" }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
.map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote()))
|
.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())
|
Command::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
|
@ -45,9 +45,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::FILES)
|
Arg::new(options::FILES)
|
||||||
.hide(true)
|
.hide(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.min_values(2)
|
.num_args(2)
|
||||||
.max_values(2)
|
|
||||||
.takes_value(true)
|
|
||||||
.value_hint(clap::ValueHint::AnyPath)
|
.value_hint(clap::ValueHint::AnyPath)
|
||||||
.value_parser(ValueParser::os_string()),
|
.value_parser(ValueParser::os_string()),
|
||||||
)
|
)
|
||||||
|
|
|
@ -50,9 +50,9 @@ fn test_link_nonexistent_file() {
|
||||||
fn test_link_one_argument() {
|
fn test_link_one_argument() {
|
||||||
let (_, mut ucmd) = at_and_ucmd!();
|
let (_, mut ucmd) = at_and_ucmd!();
|
||||||
let file = "test_link_argument";
|
let file = "test_link_argument";
|
||||||
ucmd.args(&[file]).fails().stderr_contains(
|
ucmd.args(&[file])
|
||||||
"error: The argument '<FILES>...' requires at least 2 values but only 1 was provided",
|
.fails()
|
||||||
);
|
.stderr_contains("requires 2 values");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -63,7 +63,7 @@ fn test_link_three_arguments() {
|
||||||
"test_link_argument2",
|
"test_link_argument2",
|
||||||
"test_link_argument3",
|
"test_link_argument3",
|
||||||
];
|
];
|
||||||
ucmd.args(&arguments[..]).fails().stderr_contains(
|
ucmd.args(&arguments[..])
|
||||||
format!("error: The value '{}' was provided to '<FILES>...' but it wasn't expecting any more values", arguments[2]),
|
.fails()
|
||||||
);
|
.stderr_contains("requires 2 values");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue