mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +00:00
sync: update to clap 4
This commit is contained in:
parent
02f6d4d5c8
commit
c7a7c4f2f2
2 changed files with 11 additions and 10 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/sync.rs"
|
path = "src/sync.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.2", features = ["wrap_help", "cargo"] }
|
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||||
libc = "0.2.135"
|
libc = "0.2.135"
|
||||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["wide"] }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["wide"] }
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
use clap::{crate_version, Arg, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
use nix::errno::Errno;
|
use nix::errno::Errno;
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
|
@ -175,7 +175,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
.map(|v| v.map(ToString::to_string).collect())
|
.map(|v| v.map(ToString::to_string).collect())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
if matches.is_present(options::DATA) && files.is_empty() {
|
if matches.get_flag(options::DATA) && files.is_empty() {
|
||||||
return Err(USimpleError::new(1, "--data needs at least one argument"));
|
return Err(USimpleError::new(1, "--data needs at least one argument"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,10 +218,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::if_same_then_else)]
|
#[allow(clippy::if_same_then_else)]
|
||||||
if matches.contains_id(options::FILE_SYSTEM) {
|
if matches.get_flag(options::FILE_SYSTEM) {
|
||||||
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
|
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
|
||||||
syncfs(files);
|
syncfs(files);
|
||||||
} else if matches.contains_id(options::DATA) {
|
} else if matches.get_flag(options::DATA) {
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
fdatasync(files);
|
fdatasync(files);
|
||||||
} else {
|
} else {
|
||||||
|
@ -230,7 +230,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -241,19 +241,20 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.short('f')
|
.short('f')
|
||||||
.long(options::FILE_SYSTEM)
|
.long(options::FILE_SYSTEM)
|
||||||
.conflicts_with(options::DATA)
|
.conflicts_with(options::DATA)
|
||||||
.help("sync the file systems that contain the files (Linux and Windows only)"),
|
.help("sync the file systems that contain the files (Linux and Windows only)")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::DATA)
|
Arg::new(options::DATA)
|
||||||
.short('d')
|
.short('d')
|
||||||
.long(options::DATA)
|
.long(options::DATA)
|
||||||
.conflicts_with(options::FILE_SYSTEM)
|
.conflicts_with(options::FILE_SYSTEM)
|
||||||
.help("sync only file data, no unneeded metadata (Linux only)"),
|
.help("sync only file data, no unneeded metadata (Linux only)")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(ARG_FILES)
|
Arg::new(ARG_FILES)
|
||||||
.multiple_occurrences(true)
|
.action(ArgAction::Append)
|
||||||
.takes_value(true)
|
|
||||||
.value_hint(clap::ValueHint::AnyPath),
|
.value_hint(clap::ValueHint::AnyPath),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue