Improve the --for-self encryption hint.

- Mention the configuration file, if any.

  - Fixes #472.
This commit is contained in:
Justus Winter 2024-12-02 12:15:23 +01:00
parent 04615bc768
commit b565f7ec90
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386

View File

@ -323,11 +323,19 @@ pub fn encrypt<'a, 'b: 'a>(
if ! have_one_secret && passwords.is_empty() && ! recipients.iter()
.any(|c| sq.config.encrypt_for_self().contains(&c.fingerprint()))
{
sq.hint(format_args!(
"It looks like you won't be able to decrypt the message. \
Consider adding yourself as recipient, for example by \
adding your cert to `{}` and using `--for-self`.",
cli::encrypt::ENCRYPT_FOR_SELF));
if let Some(home) = &sq.home {
sq.hint(format_args!(
"It looks like you won't be able to decrypt the message. \
Consider adding yourself as recipient, for example by \
adding your cert to `{}` in the configuration file ({}), \
and using the `--for-self` argument.",
cli::encrypt::ENCRYPT_FOR_SELF,
crate::config::ConfigFile::file_name(home).display()));
} else {
sq.hint(format_args!(
"It looks like you won't be able to decrypt the message. \
Consider adding yourself as recipient."));
}
}
// A newline to make it look nice.