Move the deamor subcommand's dispatcher and impl to its own module

This commit is contained in:
Neal H. Walfield 2023-10-17 13:53:50 +02:00
parent ddb3d8ffb1
commit 2f0fc12130
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3
4 changed files with 24 additions and 5 deletions

21
src/commands/dearmor.rs Normal file
View File

@ -0,0 +1,21 @@
use std::io;
use sequoia_openpgp as openpgp;
use openpgp::armor;
use crate::Config;
use crate::Result;
use crate::sq_cli;
pub fn dispatch(config: Config, command: sq_cli::dearmor::Command)
-> Result<()>
{
tracer!(TRACE, "dearmor::dispatch");
let mut input = command.input.open()?;
let mut output = command.output.create_safe(config.force)?;
let mut filter = armor::Reader::from_reader(&mut input, None);
io::copy(&mut filter, &mut output)?;
Ok(())
}

View File

@ -38,6 +38,7 @@ use crate::sq_cli::encrypt::EncryptionMode;
pub mod armor;
#[cfg(feature = "autocrypt")]
pub mod autocrypt;
pub mod dearmor;
pub mod decrypt;
pub mod encrypt;
pub mod sign;

View File

@ -1060,10 +1060,7 @@ fn main() -> Result<()> {
commands::armor::dispatch(config, command)?
},
SqSubcommands::Dearmor(command) => {
let mut input = command.input.open()?;
let mut output = command.output.create_safe(config.force)?;
let mut filter = armor::Reader::from_reader(&mut input, None);
io::copy(&mut filter, &mut output)?;
commands::dearmor::dispatch(config, command)?
},
#[cfg(feature = "autocrypt")]
SqSubcommands::Autocrypt(command) => {

View File

@ -13,7 +13,7 @@ use openpgp::Fingerprint;
pub mod armor;
pub mod certify;
pub mod dane;
mod dearmor;
pub mod dearmor;
pub mod decrypt;
pub mod encrypt;
pub mod export;