From 5b5e292eaedb6aae48fc7d9a6621dc6e6fa73712 Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Mon, 4 Jul 2022 22:03:10 +0200 Subject: use CliTime for revoke (merge into previous) --- sq/src/commands/revoke.rs | 26 +++----------------------- sq/src/sq_cli.rs | 6 +++--- 2 files changed, 6 insertions(+), 26 deletions(-) (limited to 'sq') diff --git a/sq/src/commands/revoke.rs b/sq/src/commands/revoke.rs index 7295d8d5..fd2dd837 100644 --- a/sq/src/commands/revoke.rs +++ b/sq/src/commands/revoke.rs @@ -20,7 +20,6 @@ use crate::{ Config, load_certs, open_or_stdin, - parse_iso8601, }; const NP: &NullPolicy = &NullPolicy::new(); @@ -80,14 +79,7 @@ pub fn revoke_certificate(config: Config, c: RevokeCertificateCommand) -> Result } let secret = secret.into_iter().next(); - // TODO use CliTime - let time = if let Some(time) = c.time { - Some(parse_iso8601(&time, chrono::NaiveTime::from_hms(0, 0, 0)) - .context(format!("Bad value passed to --time: {:?}", - time))?.into()) - } else { - None - }; + let time = c.time.map(|t| t.time.into()); // Each --notation takes two values. The iterator @@ -156,13 +148,7 @@ pub fn revoke_subkey(config: Config, c: RevokeSubkeyCommand) -> Result<()> { } let secret = secret.into_iter().next(); - let time = if let Some(time) = c.time { - Some(parse_iso8601(&time, chrono::NaiveTime::from_hms(0, 0, 0)) - .context(format!("Bad value passed to --time: {:?}", - time))?.into()) - } else { - None - }; + let time = c.time.map(|t| t.time.into()); // Each --notation takes two values. The iterator // returns them one at a time, however. @@ -222,13 +208,7 @@ pub fn revoke_userid(config: Config, c: RevokeUseridCommand) -> Result<()> { } let secret = secret.into_iter().next(); - let time = if let Some(time) = c.time { - Some(parse_iso8601(&time, chrono::NaiveTime::from_hms(0, 0, 0)) - .context(format!("Bad value passed to --time: {:?}", - time))?.into()) - } else { - None - }; + let time = c.time.map(|t| t.time.into()); // Each --notation takes two values. The iterator // returns them one at a time, however. diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs index ab005c6e..d04f16ca 100644 --- a/sq/src/sq_cli.rs +++ b/sq/src/sq_cli.rs @@ -865,7 +865,7 @@ that in the future.\"", "Chooses keys valid at the specified time and sets the revocation \ certificate's creation time", )] - pub time: Option, + pub time: Option, #[clap( long, value_names = &["NAME", "VALUE"], @@ -1019,7 +1019,7 @@ the message \"I've created a new subkey, please refresh the certificate." "Chooses keys valid at the specified time and sets the revocation \ certificate's creation time", )] - pub time: Option, + pub time: Option, #[clap( long, value_names = &["NAME", "VALUE"], @@ -1141,7 +1141,7 @@ that in the future.\"", "Chooses keys valid at the specified time and sets the revocation \ certificate's creation time", )] - pub time: Option, + pub time: Option, #[clap( long, value_names = &["NAME", "VALUE"], -- cgit v1.2.3