Merge pull request #435 from Taxrosdev/main

watch: fix minimum seconds
This commit is contained in:
Daniel Hofstetter
2025-06-11 16:02:13 +02:00
committed by GitHub
2 changed files with 19 additions and 2 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ feat_common_core = [
[workspace.dependencies]
bytesize = "2.0.0"
chrono = { version = "0.4.38", default-features = false, features = ["clock"] }
clap = { version = "4.5.4", features = ["wrap_help", "cargo"] }
clap = { version = "4.5.4", features = ["wrap_help", "cargo", "env"] }
clap_complete = "4.5.2"
clap_mangen = "0.2.20"
crossterm = "0.29.0"
+18 -1
View File
@@ -19,7 +19,12 @@ fn parse_interval(input: &str) -> Result<Duration, ParseIntError> {
// Find index where to split string into seconds and nanos
let Some(index) = input.find([',', '.']) else {
let seconds: u64 = input.parse()?;
return Ok(Duration::new(seconds, 0));
return if seconds == 0 {
Ok(Duration::from_millis(100))
} else {
Ok(Duration::new(seconds, 0))
};
};
// If the seconds string is empty, set seconds to 0
@@ -250,4 +255,16 @@ mod parse_interval_tests {
let interval = parse_interval("1.00000000000a");
assert!(interval.is_err())
}
#[test]
fn test_minimum_seconds() {
let interval = parse_interval("0");
assert_eq!(Ok(Duration::from_millis(100)), interval);
}
#[test]
fn test_minimum_nanos() {
let interval = parse_interval("0.0");
assert_eq!(Ok(Duration::from_millis(100)), interval);
}
}