Rename --recipient-cert to --recipient.

- Fixes #355.
This commit is contained in:
Justus Winter 2024-10-04 11:15:56 +02:00
parent 20fb370de7
commit ba121b2339
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
3 changed files with 17 additions and 12 deletions

1
NEWS
View File

@ -33,6 +33,7 @@
- The global `--force` flag has been renamed to `--overwrite` and
now controls whether existing files are overwritten.
- The argument `--signer-key` is now just called `--signer`.
- The argument `--recipient-cert` is now just called `--recipient`.
* Changes in 0.38.0
** Notable changes
- New subcommand `sq key subkey delete` to delete secret key

View File

@ -193,7 +193,7 @@ impl CertDesignator {
/// `Options` are the set of options to enable.
///
/// `Prefix` is a prefix to use. Using `RecipientPrefix` will
/// change, e.g., `--cert` to `--recipient-cert`.
/// change, e.g., `--email` to `--recipient-email`.
pub struct CertDesignators<Options, Prefix=NoPrefix>
{
/// The set of certificate designators.
@ -285,9 +285,10 @@ where
let prefix = Prefix::prefix();
let full_name = |name| {
if prefix == CertPrefix::prefix() && name == "cert" {
// We want `--cert`, not `--cert-cert`.
format!("cert")
if ! prefix.is_empty() && name == "cert" {
// We want `--cert`, not `--cert-cert`, or
// `--recipient` instead of `--recipient-cert`.
prefix.strip_suffix("-").expect("prefix must end with -").into()
} else {
format!("{}{}", prefix, name)
}
@ -387,8 +388,11 @@ where
if let Ok(Some(certs))
= matches.try_get_many::<KeyHandle>(
&format!("{}cert",
if prefix == "cert-" { "" } else { prefix }))
if prefix.is_empty() {
"cert"
} else {
prefix.strip_suffix("-").expect("prefix must end with -")
})
{
for cert in certs.cloned() {
designators.push(CertDesignator::Cert(cert));

View File

@ -31,7 +31,7 @@ fn try_encrypt(sq: &Sq, extra_args: &[&str],
.map(|fpr| fpr.to_string())
.collect::<Vec<_>>();
for recipient_cert in recipient_certs_.iter() {
args.push("--recipient-cert");
args.push("--recipient");
args.push(&recipient_cert);
}
@ -142,7 +142,7 @@ fn sq_encrypt_using_cert_store() -> Result<()>
.chain(cert.keys().map(|ka| KeyHandle::from(ka.keyid())))
{
assert!(
sq.encrypt_maybe(&["--recipient-cert", &kh.to_string()], b"")
sq.encrypt_maybe(&["--recipient", &kh.to_string()], b"")
.is_err());
}
@ -157,7 +157,7 @@ fn sq_encrypt_using_cert_store() -> Result<()>
.chain(cert.keys().map(|ka| KeyHandle::from(ka.keyid())))
{
let ciphertext = sq.encrypt(
&["--recipient-cert", &kh.to_string()], MESSAGE);
&["--recipient", &kh.to_string()], MESSAGE);
let plaintext = sq.decrypt(
&["--recipient-file", &key_pgp], ciphertext);
@ -240,7 +240,7 @@ fn sq_encrypt_recipient_userid() -> Result<()>
// Encryption by fingerprint should work.
encrypt(&[],
&[("--recipient-cert", &bob.fingerprint().to_string())],
&[("--recipient", &bob.fingerprint().to_string())],
&[&bob_pgp]);
// Encryption by email address and user id should fail if the
@ -351,7 +351,7 @@ fn sq_encrypt_keyring() -> Result<()>
}
for recipient in recipients.iter() {
args.push("--recipient-cert");
args.push("--recipient");
args.push(recipient);
}
@ -425,7 +425,7 @@ fn sq_encrypt_with_password() -> Result<()>
}
// Exercise various ways to encrypt a message to a recipient
// (--recipient-cert, --recipient-userid, and --recipient-email).
// (--recipient, --recipient-userid, and --recipient-email).
// When designating a certificate by name, make sure only
// authenticated certificates are used.
#[test]