mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
link: clap 3
This commit is contained in:
parent
83f39619d5
commit
0531f13cfd
3 changed files with 8 additions and 7 deletions
|
@ -18,7 +18,7 @@ path = "src/link.rs"
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
|
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
|
||||||
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
|
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
|
||||||
clap = { version = "2.33", features = ["wrap_help"] }
|
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "link"
|
name = "link"
|
||||||
|
|
|
@ -23,7 +23,7 @@ fn usage() -> String {
|
||||||
#[uucore_procs::gen_uumain]
|
#[uucore_procs::gen_uumain]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let usage = usage();
|
let usage = usage();
|
||||||
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
|
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
|
||||||
|
|
||||||
let files: Vec<_> = matches
|
let files: Vec<_> = matches
|
||||||
.values_of_os(options::FILES)
|
.values_of_os(options::FILES)
|
||||||
|
@ -36,16 +36,17 @@ 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() -> App<'static, 'static> {
|
pub fn uu_app<'a>() -> App<'a> {
|
||||||
App::new(uucore::util_name())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::FILES)
|
Arg::new(options::FILES)
|
||||||
.hidden(true)
|
.hide(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.min_values(2)
|
.min_values(2)
|
||||||
.max_values(2)
|
.max_values(2)
|
||||||
.takes_value(true),
|
.takes_value(true)
|
||||||
|
.allow_invalid_utf8(true),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,6 @@ fn test_link_three_arguments() {
|
||||||
"test_link_argument3",
|
"test_link_argument3",
|
||||||
];
|
];
|
||||||
ucmd.args(&arguments[..]).fails().stderr_contains(
|
ucmd.args(&arguments[..]).fails().stderr_contains(
|
||||||
format!("error: The value '{}' was provided to '<FILES>...', but it wasn't expecting any more values", arguments[2]),
|
format!("error: The value '{}' was provided to '<FILES>...' but it wasn't expecting any more values", arguments[2]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue