1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 05:57:46 +00:00

mv: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 14:11:31 +01:00
parent 41d567f44b
commit ba93684a7e
2 changed files with 21 additions and 19 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/mv.rs" path = "src/mv.rs"
[dependencies] [dependencies]
clap = { version = "2.33", features = ["wrap_help"] } clap = { version = "3.0", features = ["wrap_help", "cargo"] }
fs_extra = "1.1.0" fs_extra = "1.1.0"
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" }

View file

@ -82,7 +82,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
LONG_HELP, LONG_HELP,
backup_control::BACKUP_CONTROL_LONG_HELP backup_control::BACKUP_CONTROL_LONG_HELP
)) ))
.usage(&usage[..]) .override_usage(&usage[..])
.get_matches_from(args); .get_matches_from(args);
let files: Vec<OsString> = matches let files: Vec<OsString> = matches
@ -119,7 +119,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
exec(&files[..], behavior) exec(&files[..], behavior)
} }
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)
@ -130,24 +130,24 @@ pub fn uu_app() -> App<'static, 'static> {
backup_control::arguments::backup_no_args() backup_control::arguments::backup_no_args()
) )
.arg( .arg(
Arg::with_name(OPT_FORCE) Arg::new(OPT_FORCE)
.short("f") .short('f')
.long(OPT_FORCE) .long(OPT_FORCE)
.help("do not prompt before overwriting") .help("do not prompt before overwriting")
) )
.arg( .arg(
Arg::with_name(OPT_INTERACTIVE) Arg::new(OPT_INTERACTIVE)
.short("i") .short('i')
.long(OPT_INTERACTIVE) .long(OPT_INTERACTIVE)
.help("prompt before override") .help("prompt before override")
) )
.arg( .arg(
Arg::with_name(OPT_NO_CLOBBER).short("n") Arg::new(OPT_NO_CLOBBER).short('n')
.long(OPT_NO_CLOBBER) .long(OPT_NO_CLOBBER)
.help("do not overwrite an existing file") .help("do not overwrite an existing file")
) )
.arg( .arg(
Arg::with_name(OPT_STRIP_TRAILING_SLASHES) Arg::new(OPT_STRIP_TRAILING_SLASHES)
.long(OPT_STRIP_TRAILING_SLASHES) .long(OPT_STRIP_TRAILING_SLASHES)
.help("remove any trailing slashes from each SOURCE argument") .help("remove any trailing slashes from each SOURCE argument")
) )
@ -155,37 +155,39 @@ pub fn uu_app() -> App<'static, 'static> {
backup_control::arguments::suffix() backup_control::arguments::suffix()
) )
.arg( .arg(
Arg::with_name(OPT_TARGET_DIRECTORY) Arg::new(OPT_TARGET_DIRECTORY)
.short("t") .short('t')
.long(OPT_TARGET_DIRECTORY) .long(OPT_TARGET_DIRECTORY)
.help("move all SOURCE arguments into DIRECTORY") .help("move all SOURCE arguments into DIRECTORY")
.takes_value(true) .takes_value(true)
.value_name("DIRECTORY") .value_name("DIRECTORY")
.conflicts_with(OPT_NO_TARGET_DIRECTORY) .conflicts_with(OPT_NO_TARGET_DIRECTORY)
.allow_invalid_utf8(true)
) )
.arg( .arg(
Arg::with_name(OPT_NO_TARGET_DIRECTORY) Arg::new(OPT_NO_TARGET_DIRECTORY)
.short("T") .short('T')
.long(OPT_NO_TARGET_DIRECTORY). .long(OPT_NO_TARGET_DIRECTORY).
help("treat DEST as a normal file") help("treat DEST as a normal file")
) )
.arg( .arg(
Arg::with_name(OPT_UPDATE) Arg::new(OPT_UPDATE)
.short("u") .short('u')
.long(OPT_UPDATE) .long(OPT_UPDATE)
.help("move only when the SOURCE file is newer than the destination file or when the destination file is missing") .help("move only when the SOURCE file is newer than the destination file or when the destination file is missing")
) )
.arg( .arg(
Arg::with_name(OPT_VERBOSE) Arg::new(OPT_VERBOSE)
.short("v") .short('v')
.long(OPT_VERBOSE).help("explain what is being done") .long(OPT_VERBOSE).help("explain what is being done")
) )
.arg( .arg(
Arg::with_name(ARG_FILES) Arg::new(ARG_FILES)
.multiple(true) .multiple_occurrences(true)
.takes_value(true) .takes_value(true)
.min_values(2) .min_values(2)
.required(true) .required(true)
.allow_invalid_utf8(true)
) )
} }