mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #4927 from cakebaker/bump_fundu_and_fix_compile_errors
Bump fundu to 1.0.0 and fix compile errors
This commit is contained in:
commit
63b84fed8b
4 changed files with 18 additions and 13 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -956,9 +956,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "fundu"
|
||||
version = "0.5.1"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a37cfff04a32112c22c5497b20b0b09100fca406e76afd47b2ba5ab33d7a851"
|
||||
checksum = "47af3b646bdd738395be2db903fc11a5923b5e206016b8d4ad6db890bcae9bd5"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
|
|
|
@ -280,7 +280,7 @@ filetime = "0.2"
|
|||
fnv = "1.0.7"
|
||||
fs_extra = "1.3.0"
|
||||
fts-sys = "0.2"
|
||||
fundu = "0.5.1"
|
||||
fundu = "1.0.0"
|
||||
gcd = "2.3"
|
||||
glob = "0.3.1"
|
||||
half = "2.2"
|
||||
|
|
|
@ -14,7 +14,7 @@ use uucore::{
|
|||
};
|
||||
|
||||
use clap::{crate_version, Arg, ArgAction, Command};
|
||||
use fundu::{self, DurationParser, ParseError};
|
||||
use fundu::{self, DurationParser, ParseError, SaturatingInto};
|
||||
|
||||
static ABOUT: &str = help_about!("sleep.md");
|
||||
const USAGE: &str = help_usage!("sleep.md");
|
||||
|
@ -63,7 +63,7 @@ pub fn uu_app() -> Command {
|
|||
fn sleep(args: &[&str]) -> UResult<()> {
|
||||
let mut arg_error = false;
|
||||
|
||||
use fundu::TimeUnit::*;
|
||||
use fundu::TimeUnit::{Day, Hour, Minute, Second};
|
||||
let parser = DurationParser::with_time_units(&[Second, Minute, Hour, Day]);
|
||||
|
||||
let sleep_dur = args
|
||||
|
@ -91,7 +91,9 @@ fn sleep(args: &[&str]) -> UResult<()> {
|
|||
None
|
||||
}
|
||||
})
|
||||
.fold(Duration::ZERO, |acc, n| acc.saturating_add(n));
|
||||
.fold(Duration::ZERO, |acc, n| {
|
||||
acc.saturating_add(SaturatingInto::<std::time::Duration>::saturating_into(n))
|
||||
});
|
||||
|
||||
if arg_error {
|
||||
return Err(UUsageError::new(1, ""));
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::paths::Input;
|
|||
use crate::{parse, platform, Quotable};
|
||||
use clap::crate_version;
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use fundu::DurationParser;
|
||||
use fundu::{DurationParser, SaturatingInto};
|
||||
use is_terminal::IsTerminal;
|
||||
use same_file::Handle;
|
||||
use std::collections::VecDeque;
|
||||
|
@ -235,12 +235,15 @@ impl Settings {
|
|||
// `DURATION::MAX` or `infinity` was given
|
||||
// * not applied here but it supports customizable time units and provides better error
|
||||
// messages
|
||||
settings.sleep_sec =
|
||||
DurationParser::without_time_units()
|
||||
.parse(source)
|
||||
.map_err(|_| {
|
||||
UUsageError::new(1, format!("invalid number of seconds: '{source}'"))
|
||||
})?;
|
||||
settings.sleep_sec = match DurationParser::without_time_units().parse(source) {
|
||||
Ok(duration) => SaturatingInto::<std::time::Duration>::saturating_into(duration),
|
||||
Err(_) => {
|
||||
return Err(UUsageError::new(
|
||||
1,
|
||||
format!("invalid number of seconds: '{source}'"),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(s) = matches.get_one::<String>(options::MAX_UNCHANGED_STATS) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue