When reading from a file, default to writing to stdout.

- Change `sq key revoke`, `sq key userid revoke`, and `sq key subkey
    revoke` to default to writing to stdout when reading from a file.
This commit is contained in:
Neal H. Walfield 2024-05-29 09:33:10 +02:00
parent 3debf8b584
commit 42cca6b172
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3
3 changed files with 23 additions and 3 deletions

View File

@ -9,6 +9,7 @@ use openpgp::Result;
use crate::Sq;
use crate::cli::key::RevokeCommand;
use crate::cli::types::FileOrStdout;
use crate::common::RevocationOutput;
use crate::common::get_secret_signer;
use crate::parse_notations;
@ -85,9 +86,15 @@ impl RevocationOutput for CertificateRevocation
/// Revoke a certificate
pub fn certificate_revoke(
sq: Sq,
command: RevokeCommand,
mut command: RevokeCommand,
) -> Result<()> {
let cert = if let Some(file) = command.cert_file {
if command.output.is_none() {
// None means to write to the cert store. When reading
// from a file, we want to write to stdout by default.
command.output = Some(FileOrStdout::new(None));
}
let br = file.open()?;
Cert::from_buffered_reader(br)?
} else if let Some(kh) = command.cert {

View File

@ -20,6 +20,7 @@ use crate::cli::key::SubkeyAddCommand;
use crate::cli::key::SubkeyCommand;
use crate::cli::key::SubkeyRevokeCommand;
use crate::cli::types::EncryptPurpose;
use crate::cli::types::FileOrStdout;
use crate::common;
use crate::common::NULL_POLICY;
use crate::common::RevocationOutput;
@ -223,9 +224,15 @@ fn subkey_add(
/// revocation fails.
pub fn subkey_revoke(
sq: Sq,
command: SubkeyRevokeCommand,
mut command: SubkeyRevokeCommand,
) -> Result<()> {
let cert = if let Some(file) = command.cert_file {
if command.output.is_none() {
// None means to write to the cert store. When reading
// from a file, we want to write to stdout by default.
command.output = Some(FileOrStdout::new(None));
}
let br = file.open()?;
Cert::from_buffered_reader(br)?
} else if let Some(kh) = command.cert {

View File

@ -396,9 +396,15 @@ signatures on other User IDs to make the key valid again.",
/// [`NotationData`] fails or if the eventual revocation fails.
pub fn userid_revoke(
sq: Sq,
command: UseridRevokeCommand,
mut command: UseridRevokeCommand,
) -> Result<()> {
let cert = if let Some(file) = command.cert_file {
if command.output.is_none() {
// None means to write to the cert store. When reading
// from a file, we want to write to stdout by default.
command.output = Some(FileOrStdout::new(None));
}
let br = file.open()?;
Cert::from_buffered_reader(br)?
} else if let Some(kh) = command.cert {