Align the output of sq cert list with sq key list.

This commit is contained in:
Justus Winter 2024-10-18 17:49:10 +02:00
parent fece9407ef
commit bc61c8a84c
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386

View File

@ -14,6 +14,7 @@ use cert_store::Store;
use sequoia_wot as wot; use sequoia_wot as wot;
use wot::Path; use wot::Path;
use crate::Convert;
use crate::Sq; use crate::Sq;
use crate::commands::pki::output::OutputType; use crate::commands::pki::output::OutputType;
use crate::Time; use crate::Time;
@ -76,30 +77,37 @@ impl OutputType for ConciseHumanReadableOutputNetwork<'_, '_, '_> {
}); });
if show_cert { if show_cert {
let expired = vc let expiration_info = vc
.as_ref() .as_ref()
.map(|vc| { .and_then(|vc| {
if let Some(t) = vc.primary_key().key_expiration_time() { if let Some(t) = vc.primary_key().key_expiration_time() {
if t < SystemTime::now() { if t < SystemTime::now() {
format!(" expired on {}", Some(format!("expired on {}",
Time::try_from(t) Time::try_from(t)
.expect("is an OpenPGP timestamp")) .expect("is an OpenPGP timestamp")))
} else { } else {
format!(" will expire on {}", Some(format!("will expire on {}",
Time::try_from(t) Time::try_from(t)
.expect("is an OpenPGP timestamp")) .expect("is an OpenPGP timestamp")))
} }
} else { } else {
"".to_string() None
} }
}) });
.unwrap_or("".to_string());
if ! first_shown { if ! first_shown {
wprintln!(); wprintln!();
} }
wprintln!("{}{}", fingerprint, expired); wprintln!(initial_indent = " - ", "{}", fingerprint);
wprintln!(initial_indent = " - ", "created {}",
self.current_cert.as_ref()
.expect("show_cert is true, there is a current cert")
.primary_key().key().creation_time().convert());
if let Some(info) = expiration_info {
wprintln!(initial_indent = " - ", "{}", info);
}
wprintln!();
} }
let revoked = vc let revoked = vc
@ -120,7 +128,7 @@ impl OutputType for ConciseHumanReadableOutputNetwork<'_, '_, '_> {
.next() .next()
}); });
wprintln!(initial_indent = " ", "[ {} ] {}", wprintln!(initial_indent = " - ", "[ {} ] {}",
if revoked.is_some() { if revoked.is_some() {
"revoked".to_string() "revoked".to_string()
} else if aggregated_amount >= self.required_amount { } else if aggregated_amount >= self.required_amount {