diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2022-07-04 22:03:10 +0200 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2022-07-05 13:57:06 +0200 |
commit | 5b5e292eaedb6aae48fc7d9a6621dc6e6fa73712 (patch) | |
tree | 35a0d2d3934fd11eb8d463cec6d6dba971105884 | |
parent | 983b4ccd33fcaa772027715816acd0aa58a17145 (diff) |
use CliTime for revoke (merge into previous)
-rw-r--r-- | sq/src/commands/revoke.rs | 26 | ||||
-rw-r--r-- | sq/src/sq_cli.rs | 6 |
2 files changed, 6 insertions, 26 deletions
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<String>, + pub time: Option<CliTime>, #[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<String>, + pub time: Option<CliTime>, #[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<String>, + pub time: Option<CliTime>, #[clap( long, value_names = &["NAME", "VALUE"], |