mirror of
https://codeberg.org/tyy/aspm
synced 2024-12-23 01:19:28 -07:00
Add success text to import gpg
This commit is contained in:
parent
91a4a42fe6
commit
4f83bb9a3f
1 changed files with 31 additions and 21 deletions
|
@ -9,6 +9,7 @@ use data_encoding::{BASE64URL_NOPAD, BASE64_NOPAD};
|
||||||
use dialoguer::{theme::ColorfulTheme, Password};
|
use dialoguer::{theme::ColorfulTheme, Password};
|
||||||
use elliptic_curve::sec1::{Coordinates, ToEncodedPoint};
|
use elliptic_curve::sec1::{Coordinates, ToEncodedPoint};
|
||||||
use gpgme::{Context as GpgContext, PassphraseRequest};
|
use gpgme::{Context as GpgContext, PassphraseRequest};
|
||||||
|
use indoc::printdoc;
|
||||||
use pgp::{
|
use pgp::{
|
||||||
crypto::ecc_curve::ECCCurve,
|
crypto::ecc_curve::ECCCurve,
|
||||||
types::{EcdsaPublicParams, KeyTrait, PlainSecretParams, PublicParams, SecretParams},
|
types::{EcdsaPublicParams, KeyTrait, PlainSecretParams, PublicParams, SecretParams},
|
||||||
|
@ -38,9 +39,7 @@ impl AspmSubcommand for KeysImportGpgCommand {
|
||||||
.secret_keys()
|
.secret_keys()
|
||||||
.context("Unable to fetch GPG secret keys")?
|
.context("Unable to fetch GPG secret keys")?
|
||||||
{
|
{
|
||||||
let Ok(key) = key else {
|
let Ok(key) = key else { continue };
|
||||||
continue
|
|
||||||
};
|
|
||||||
|
|
||||||
if key.fingerprint().unwrap_or("") != self.fingerprint
|
if key.fingerprint().unwrap_or("") != self.fingerprint
|
||||||
&& key
|
&& key
|
||||||
|
@ -119,7 +118,8 @@ impl AspmSubcommand for KeysImportGpgCommand {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}) else {
|
})
|
||||||
|
else {
|
||||||
eprintln!("Key being imported has no primary uid. This must be set, as it is used for the key alias.");
|
eprintln!("Key being imported has no primary uid. This must be set, as it is used for the key alias.");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
};
|
};
|
||||||
|
@ -255,7 +255,7 @@ impl AspmSubcommand for KeysImportGpgCommand {
|
||||||
|
|
||||||
let entry = keys::ActiveModel {
|
let entry = keys::ActiveModel {
|
||||||
fingerprint: ActiveValue::Set(asp_key.fingerprint.clone()),
|
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())),
|
alias: ActiveValue::Set(format!("{uid}", uid = uid.id.id())),
|
||||||
encrypted: ActiveValue::Set(encrypted),
|
encrypted: ActiveValue::Set(encrypted),
|
||||||
};
|
};
|
||||||
|
@ -267,6 +267,16 @@ impl AspmSubcommand for KeysImportGpgCommand {
|
||||||
bail!("The key was unable to be saved to the database")
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue