summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-04-27 10:01:50 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-05-11 11:13:05 +0200
commit67137f5b040cdf72e1d190c14eee336c86bf26c2 (patch)
tree337d25368a85b5c35a5f905991753735f88673af /src/cli.rs
parent6829525b6109b10a320860cee61208d5b016e643 (diff)
Refactor: Use human readable time format
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/cli.rs b/src/cli.rs
index a298f74..931a532 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1208,6 +1208,25 @@ fn arg_older_than_date<'a>() -> Arg<'a> {
.takes_value(true)
.value_name("DATE")
.about("List only containers that are older than DATE")
+ .long_about(r#"
+ List only containers that are older than DATE
+
+ DATE can be a freeform date, for example '2h'
+
+ Supported suffixes:
+
+ nsec, ns -- nanoseconds
+ usec, us -- microseconds
+ msec, ms -- milliseconds
+ seconds, second, sec, s
+ minutes, minute, min, m
+ hours, hour, hr, h
+ days, day, d
+ weeks, week, w
+ months, month, M -- defined as 30.44 days
+ years, year, y -- defined as 365.25 days
+
+ "#)
.validator(parse_date_from_string)
.conflicts_with("newer_than")
}
@@ -1220,12 +1239,31 @@ fn arg_newer_than_date<'a>() -> Arg<'a> {
.takes_value(true)
.value_name("DATE")
.about("List only containers that are newer than DATE")
+ .long_about(r#"
+ List only containers that are newer than DATE
+
+ DATE can be a freeform date, for example '2h'
+
+ Supported suffixes:
+
+ nsec, ns -- nanoseconds
+ usec, us -- microseconds
+ msec, ms -- milliseconds
+ seconds, second, sec, s
+ minutes, minute, min, m
+ hours, hour, hr, h
+ days, day, d
+ weeks, week, w
+ months, month, M -- defined as 30.44 days
+ years, year, y -- defined as 365.25 days
+
+ "#)
.validator(parse_date_from_string)
.conflicts_with("older_than")
}
fn parse_date_from_string(s: &str) -> std::result::Result<(), String> {
- humantime::parse_rfc3339_weak(s).map_err(|e| e.to_string()).map(|_| ())
+ humantime::parse_duration(s).map_err(|e| e.to_string()).map(|_| ())
}
fn parse_usize(s: &str) -> std::result::Result<(), String> {