summaryrefslogtreecommitdiffstats
path: root/sq/src/sq.rs
diff options
context:
space:
mode:
Diffstat (limited to 'sq/src/sq.rs')
-rw-r--r--sq/src/sq.rs45
1 files changed, 3 insertions, 42 deletions
diff --git a/sq/src/sq.rs b/sq/src/sq.rs
index 9e11e44c..f04f4b36 100644
--- a/sq/src/sq.rs
+++ b/sq/src/sq.rs
@@ -2,7 +2,7 @@
use anyhow::Context as _;
use std::fs::OpenOptions;
-use std::io::{self, Write};
+use std::io;
use std::path::{Path, PathBuf};
use std::time::Duration;
use chrono::{DateTime, offset::Utc};
@@ -15,7 +15,6 @@ use openpgp::{
Result,
};
use crate::openpgp::{armor, Cert};
-use sequoia_autocrypt as autocrypt;
use crate::openpgp::crypto::Password;
use crate::openpgp::fmt::hex;
use crate::openpgp::types::KeyFlags;
@@ -541,46 +540,8 @@ fn main() -> Result<()> {
let mut filter = armor::Reader::new(&mut input, None);
io::copy(&mut filter, &mut output)?;
},
- ("autocrypt", Some(m)) => {
- match m.subcommand() {
- ("decode", Some(m)) => {
- let input = open_or_stdin(m.value_of("input"))?;
- let mut output =
- create_or_stdout_pgp(m.value_of("output"), force,
- m.is_present("binary"),
- armor::Kind::PublicKey)?;
- let ac = autocrypt::AutocryptHeaders::from_reader(input)?;
- for h in &ac.headers {
- if let Some(ref cert) = h.key {
- cert.serialize(&mut output)?;
- }
- }
- output.finalize()?;
- },
- ("encode-sender", Some(m)) => {
- let input = open_or_stdin(m.value_of("input"))?;
- let mut output = create_or_stdout(m.value_of("output"),
- force)?;
- let cert = Cert::from_reader(input)?;
- let addr = m.value_of("address").map(|a| a.to_string())
- .or_else(|| {
- cert.with_policy(policy, None)
- .and_then(|vcert| vcert.primary_userid()).ok()
- .map(|ca| ca.userid().to_string())
- });
- let ac = autocrypt::AutocryptHeader::new_sender(
- policy,
- &cert,
- &addr.ok_or(anyhow::anyhow!(
- "No well-formed primary userid found, use \
- --address to specify one"))?,
- m.value_of("prefer-encrypt").expect("has default"))?;
- write!(&mut output, "Autocrypt: ")?;
- ac.serialize(&mut output)?;
- },
- _ => unreachable!(),
- }
- },
+ #[cfg(feature = "autocrypt")]
+ ("autocrypt", Some(m)) => commands::autocrypt::dispatch(config, m)?,
("inspect", Some(m)) => {
let mut output = create_or_stdout(m.value_of("output"), force)?;