mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 11:46:17 +00:00
date: update to clap 4
This commit is contained in:
parent
5556d23e21
commit
8183f4cf06
2 changed files with 12 additions and 15 deletions
|
@ -16,7 +16,7 @@ path = "src/date.rs"
|
|||
|
||||
[dependencies]
|
||||
chrono = { version="^0.4.19", default-features=false, features=["std", "alloc", "clock"]}
|
||||
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" }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use chrono::{DateTime, FixedOffset, Local, Offset, Utc};
|
||||
#[cfg(windows)]
|
||||
use chrono::{Datelike, Timelike};
|
||||
use clap::{crate_version, Arg, Command};
|
||||
use clap::{crate_version, Arg, ArgAction, Command};
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
||||
use libc::{clock_settime, timespec, CLOCK_REALTIME};
|
||||
use std::fs::File;
|
||||
|
@ -160,7 +160,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
.map(|mut iter| iter.next().unwrap_or(&DATE.to_string()).as_str().into())
|
||||
{
|
||||
Format::Iso8601(fmt)
|
||||
} else if matches.contains_id(OPT_RFC_EMAIL) {
|
||||
} else if matches.get_flag(OPT_RFC_EMAIL) {
|
||||
Format::Rfc5322
|
||||
} else if let Some(fmt) = matches
|
||||
.get_one::<String>(OPT_RFC_3339)
|
||||
|
@ -191,7 +191,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
};
|
||||
|
||||
let settings = Settings {
|
||||
utc: matches.contains_id(OPT_UNIVERSAL),
|
||||
utc: matches.get_flag(OPT_UNIVERSAL),
|
||||
format,
|
||||
date_source,
|
||||
set_to,
|
||||
|
@ -257,7 +257,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(ABOUT)
|
||||
|
@ -267,7 +267,6 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Arg::new(OPT_DATE)
|
||||
.short('d')
|
||||
.long(OPT_DATE)
|
||||
.takes_value(true)
|
||||
.value_name("STRING")
|
||||
.help("display time described by STRING, not 'now'"),
|
||||
)
|
||||
|
@ -275,7 +274,6 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Arg::new(OPT_FILE)
|
||||
.short('f')
|
||||
.long(OPT_FILE)
|
||||
.takes_value(true)
|
||||
.value_name("DATEFILE")
|
||||
.value_hint(clap::ValueHint::FilePath)
|
||||
.help("like --date; once for each line of DATEFILE"),
|
||||
|
@ -284,7 +282,6 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Arg::new(OPT_ISO_8601)
|
||||
.short('I')
|
||||
.long(OPT_ISO_8601)
|
||||
.takes_value(true)
|
||||
.value_name("FMT")
|
||||
.help(ISO_8601_HELP_STRING),
|
||||
)
|
||||
|
@ -292,25 +289,25 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Arg::new(OPT_RFC_EMAIL)
|
||||
.short('R')
|
||||
.long(OPT_RFC_EMAIL)
|
||||
.help(RFC_5322_HELP_STRING),
|
||||
.help(RFC_5322_HELP_STRING)
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(OPT_RFC_3339)
|
||||
.long(OPT_RFC_3339)
|
||||
.takes_value(true)
|
||||
.value_name("FMT")
|
||||
.help(RFC_3339_HELP_STRING),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(OPT_DEBUG)
|
||||
.long(OPT_DEBUG)
|
||||
.help("annotate the parsed date, and warn about questionable usage to stderr"),
|
||||
.help("annotate the parsed date, and warn about questionable usage to stderr")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(OPT_REFERENCE)
|
||||
.short('r')
|
||||
.long(OPT_REFERENCE)
|
||||
.takes_value(true)
|
||||
.value_name("FILE")
|
||||
.value_hint(clap::ValueHint::AnyPath)
|
||||
.help("display the last modification time of FILE"),
|
||||
|
@ -319,7 +316,6 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Arg::new(OPT_SET)
|
||||
.short('s')
|
||||
.long(OPT_SET)
|
||||
.takes_value(true)
|
||||
.value_name("STRING")
|
||||
.help(OPT_SET_HELP_STRING),
|
||||
)
|
||||
|
@ -328,9 +324,10 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.short('u')
|
||||
.long(OPT_UNIVERSAL)
|
||||
.alias(OPT_UNIVERSAL_2)
|
||||
.help("print or set Coordinated Universal Time (UTC)"),
|
||||
.help("print or set Coordinated Universal Time (UTC)")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(Arg::new(OPT_FORMAT).multiple_occurrences(false))
|
||||
.arg(Arg::new(OPT_FORMAT))
|
||||
}
|
||||
|
||||
/// Return the appropriate format string for the given settings.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue