1
0
Fork 0
mirror of https://codeberg.org/tyy/aspm synced 2024-12-22 21:49:28 -07:00

Add success text to import gpg

This commit is contained in:
Tyler Beckman 2023-09-28 13:13:57 -06:00
parent 91a4a42fe6
commit 4f83bb9a3f
Signed by: Ty
GPG key ID: 2813440C772555A4

View file

@ -9,6 +9,7 @@ use data_encoding::{BASE64URL_NOPAD, BASE64_NOPAD};
use dialoguer::{theme::ColorfulTheme, Password};
use elliptic_curve::sec1::{Coordinates, ToEncodedPoint};
use gpgme::{Context as GpgContext, PassphraseRequest};
use indoc::printdoc;
use pgp::{
crypto::ecc_curve::ECCCurve,
types::{EcdsaPublicParams, KeyTrait, PlainSecretParams, PublicParams, SecretParams},
@ -38,9 +39,7 @@ impl AspmSubcommand for KeysImportGpgCommand {
.secret_keys()
.context("Unable to fetch GPG secret keys")?
{
let Ok(key) = key else {
continue
};
let Ok(key) = key else { continue };
if key.fingerprint().unwrap_or("") != self.fingerprint
&& key
@ -119,7 +118,8 @@ impl AspmSubcommand for KeysImportGpgCommand {
} else {
None
}
}) else {
})
else {
eprintln!("Key being imported has no primary uid. This must be set, as it is used for the key alias.");
std::process::exit(1);
};
@ -255,7 +255,7 @@ impl AspmSubcommand for KeysImportGpgCommand {
let entry = keys::ActiveModel {
fingerprint: ActiveValue::Set(asp_key.fingerprint.clone()),
key_type: ActiveValue::Set(asp_key.key_type.into()),
key_type: ActiveValue::Set(asp_key.key_type.clone().into()),
alias: ActiveValue::Set(format!("{uid}", uid = uid.id.id())),
encrypted: ActiveValue::Set(encrypted),
};
@ -267,6 +267,16 @@ impl AspmSubcommand for KeysImportGpgCommand {
bail!("The key was unable to be saved to the database")
}
printdoc! {
"
Successfully imported key!
ASP Fingerprint: {fpr}
Type: {type:?}
",
fpr = asp_key.fingerprint,
r#type = asp_key.key_type
};
Ok(())
}
}