File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ feat_common_core = [
5353[workspace .dependencies ]
5454bytesize = " 2.0.0"
5555chrono = { version = " 0.4.38" , default-features = false , features = [" clock" ] }
56- clap = { version = " 4.5.4" , features = [" wrap_help" , " cargo" ] }
56+ clap = { version = " 4.5.4" , features = [" wrap_help" , " cargo" , " env " ] }
5757clap_complete = " 4.5.2"
5858clap_mangen = " 0.2.20"
5959crossterm = " 0.29.0"
Original file line number Diff line number Diff line change @@ -19,7 +19,12 @@ fn parse_interval(input: &str) -> Result<Duration, ParseIntError> {
1919 // Find index where to split string into seconds and nanos
2020 let Some ( index) = input. find ( [ ',' , '.' ] ) else {
2121 let seconds: u64 = input. parse ( ) ?;
22- return Ok ( Duration :: new ( seconds, 0 ) ) ;
22+
23+ return if seconds == 0 {
24+ Ok ( Duration :: from_millis ( 100 ) )
25+ } else {
26+ Ok ( Duration :: new ( seconds, 0 ) )
27+ } ;
2328 } ;
2429
2530 // If the seconds string is empty, set seconds to 0
@@ -250,4 +255,16 @@ mod parse_interval_tests {
250255 let interval = parse_interval ( "1.00000000000a" ) ;
251256 assert ! ( interval. is_err( ) )
252257 }
258+
259+ #[ test]
260+ fn test_minimum_seconds ( ) {
261+ let interval = parse_interval ( "0" ) ;
262+ assert_eq ! ( Ok ( Duration :: from_millis( 100 ) ) , interval) ;
263+ }
264+
265+ #[ test]
266+ fn test_minimum_nanos ( ) {
267+ let interval = parse_interval ( "0.0" ) ;
268+ assert_eq ! ( Ok ( Duration :: from_millis( 100 ) ) , interval) ;
269+ }
253270}
You can’t perform that action at this time.
0 commit comments