From c9477e05d3c96aa6fb2e1783c329ec80bbfa760f Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Mon, 8 Aug 2022 16:55:05 +0200 Subject: sq: DRY entity names in module paths. --- sq/src/commands/autocrypt.rs | 9 +++---- sq/src/commands/certify.rs | 4 +-- sq/src/commands/inspect.rs | 4 +-- sq/src/commands/key.rs | 56 ++++++++++++++++++++++------------------ sq/src/commands/keyring.rs | 6 ++--- sq/src/commands/mod.rs | 28 ++++++++++---------- sq/src/commands/net.rs | 23 ++++++++--------- sq/src/commands/revoke.rs | 20 ++++++-------- sq/src/sq.rs | 10 +++---- sq/src/sq_cli/armor.rs | 2 +- sq/src/sq_cli/autocrypt.rs | 14 +++++----- sq/src/sq_cli/certify.rs | 2 +- sq/src/sq_cli/dearmor.rs | 2 +- sq/src/sq_cli/decrypt.rs | 2 +- sq/src/sq_cli/encrypt.rs | 14 +++++----- sq/src/sq_cli/inspect.rs | 2 +- sq/src/sq_cli/key.rs | 48 +++++++++++++++++----------------- sq/src/sq_cli/keyring.rs | 26 +++++++++---------- sq/src/sq_cli/keyserver.rs | 14 +++++----- sq/src/sq_cli/mod.rs | 32 +++++++++++------------ sq/src/sq_cli/output_versions.rs | 2 +- sq/src/sq_cli/packet.rs | 22 ++++++++-------- sq/src/sq_cli/revoke.rs | 18 ++++++------- sq/src/sq_cli/sign.rs | 2 +- sq/src/sq_cli/verify.rs | 2 +- sq/src/sq_cli/wkd.rs | 22 ++++++++-------- 26 files changed, 193 insertions(+), 193 deletions(-) diff --git a/sq/src/commands/autocrypt.rs b/sq/src/commands/autocrypt.rs index 748e71ea..129f438e 100644 --- a/sq/src/commands/autocrypt.rs +++ b/sq/src/commands/autocrypt.rs @@ -14,12 +14,11 @@ use crate::{ sq_cli, }; -use sq_cli::autocrypt::{AutocryptSubcommands, AutocryptCommand}; - -pub fn dispatch(config: Config, c: &AutocryptCommand) -> Result<()> { +pub fn dispatch(config: Config, c: &sq_cli::autocrypt::Command) -> Result<()> { + use sq_cli::autocrypt::Subcommands::*; match &c.subcommand { - AutocryptSubcommands::Decode(command) => { + Decode(command) => { let input = open_or_stdin(command.io.input.as_deref())?; let mut output = config.create_or_stdout_pgp( command.io.output.as_deref(), @@ -34,7 +33,7 @@ pub fn dispatch(config: Config, c: &AutocryptCommand) -> Result<()> { } output.finalize()?; } - AutocryptSubcommands::EncodeSender(command) => { + EncodeSender(command) => { let input = open_or_stdin(command.io.input.as_deref())?; let mut output = config.create_or_stdout_safe(command.io.output.as_deref())?; diff --git a/sq/src/commands/certify.rs b/sq/src/commands/certify.rs index ff790b7d..d3121dd8 100644 --- a/sq/src/commands/certify.rs +++ b/sq/src/commands/certify.rs @@ -18,9 +18,9 @@ use crate::SECONDS_IN_YEAR; use crate::commands::get_certification_keys; use crate::commands::GetKeysOptions; -use crate::sq_cli::certify::CertifyCommand; +use crate::sq_cli::certify; -pub fn certify(config: Config, c: CertifyCommand) +pub fn certify(config: Config, c: certify::Command) -> Result<()> { let certifier = c.certifier; diff --git a/sq/src/commands/inspect.rs b/sq/src/commands/inspect.rs index 57069c65..ca10e6ef 100644 --- a/sq/src/commands/inspect.rs +++ b/sq/src/commands/inspect.rs @@ -17,9 +17,9 @@ use super::dump::Convert; use crate::SECONDS_IN_YEAR; use crate::SECONDS_IN_DAY; -use crate::sq_cli::inspect::InspectCommand; +use crate::sq_cli::inspect; -pub fn inspect(c: InspectCommand, policy: &dyn Policy, output: &mut dyn io::Write) +pub fn inspect(c: inspect::Command, policy: &dyn Policy, output: &mut dyn io::Write) -> Result<()> { let print_certifications = c.certifications; diff --git a/sq/src/commands/key.rs b/sq/src/commands/key.rs index 7c07f242..2be2a0f7 100644 --- a/sq/src/commands/key.rs +++ b/sq/src/commands/key.rs @@ -24,18 +24,10 @@ use crate::SECONDS_IN_YEAR; use crate::parse_duration; use crate::decrypt_key; -use crate::sq_cli::key::KeyCommand; -use crate::sq_cli::key::KeyGenerateCommand; -use crate::sq_cli::key::KeyPasswordCommand; -use crate::sq_cli::key::KeyUseridCommand; -use crate::sq_cli::key::KeyUseridAddCommand; -use crate::sq_cli::key::KeyUseridStripCommand; -use crate::sq_cli::key::KeyExtractCertCommand; -use crate::sq_cli::key::KeyAdoptCommand; -use crate::sq_cli::key::KeyAttestCertificationsCommand; -use crate::sq_cli::key::KeySubcommands::*; - -pub fn dispatch(config: Config, command: KeyCommand) -> Result<()> { +use crate::sq_cli; + +pub fn dispatch(config: Config, command: sq_cli::key::Command) -> Result<()> { + use sq_cli::key::Subcommands::*; match command.subcommand { Generate(c) => generate(config, c)?, Password(c) => password(config, c)?, @@ -47,7 +39,10 @@ pub fn dispatch(config: Config, command: KeyCommand) -> Result<()> { Ok(()) } -fn generate(config: Config, command: KeyGenerateCommand) -> Result<()> { +fn generate( + config: Config, + command: sq_cli::key::GenerateCommand, +) -> Result<()> { let mut builder = CertBuilder::new(); // User ID @@ -91,7 +86,7 @@ fn generate(config: Config, command: KeyGenerateCommand) -> Result<()> { } // Cipher Suite - use crate::sq_cli::key::KeyCipherSuite::*; + use sq_cli::key::CipherSuite::*; match command.cipher_suite { Rsa3k => { builder = builder.set_cipher_suite(CipherSuite::RSA3k); @@ -130,7 +125,7 @@ fn generate(config: Config, command: KeyGenerateCommand) -> Result<()> { } // Encryption Capability - use crate::sq_cli::key::KeyEncryptPurpose::*; + use sq_cli::key::EncryptPurpose::*; match (command.can_encrypt, command.cannot_encrypt) { (Some(Universal), false) | (None, false) => { builder = builder.add_subkey(KeyFlags::empty() @@ -228,7 +223,10 @@ fn generate(config: Config, command: KeyGenerateCommand) -> Result<()> { Ok(()) } -fn password(config: Config, command: KeyPasswordCommand) -> Result<()> { +fn password( + config: Config, + command: sq_cli::key::PasswordCommand, +) -> Result<()> { let input = open_or_stdin(command.io.input.as_deref())?; let key = Cert::from_reader(input)?; @@ -296,7 +294,10 @@ fn password(config: Config, command: KeyPasswordCommand) -> Result<()> { Ok(()) } -fn extract_cert(config: Config, command: KeyExtractCertCommand) -> Result<()> { +fn extract_cert( + config: Config, + command: sq_cli::key::ExtractCertCommand, +) -> Result<()> { let input = open_or_stdin(command.io.input.as_deref())?; let mut output = config.create_or_stdout_safe(command.io.output.as_deref())?; @@ -309,16 +310,16 @@ fn extract_cert(config: Config, command: KeyExtractCertCommand) -> Result<()> { Ok(()) } -fn userid(config: Config, command: KeyUseridCommand) -> Result<()> { +fn userid(config: Config, command: sq_cli::key::UseridCommand) -> Result<()> { match command { - KeyUseridCommand::Add(c) => userid_add(config, c)?, - KeyUseridCommand::Strip(c) => userid_strip(config, c)?, + sq_cli::key::UseridCommand::Add(c) => userid_add(config, c)?, + sq_cli::key::UseridCommand::Strip(c) => userid_strip(config, c)?, } Ok(()) } -fn userid_add(config: Config, command: KeyUseridAddCommand) -> Result<()> { +fn userid_add(config: Config, command: sq_cli::key::UseridAddCommand) -> Result<()> { let input = open_or_stdin(command.io.input.as_deref())?; let key = Cert::from_reader(input)?; @@ -462,7 +463,10 @@ fn userid_add(config: Config, command: KeyUseridAddCommand) -> Result<()> { Ok(()) } -fn userid_strip(config: Config, command: KeyUseridStripCommand) -> Result<()> { +fn userid_strip( + config: Config, + command: sq_cli::key::UseridStripCommand, +) -> Result<()> { let input = open_or_stdin(command.io.input.as_deref())?; let key = Cert::from_reader(input)?; @@ -511,7 +515,7 @@ signatures on other User IDs to make the key valid again.", Ok(()) } -fn adopt(config: Config, command: KeyAdoptCommand) -> Result<()> { +fn adopt(config: Config, command: sq_cli::key::AdoptCommand) -> Result<()> { let input = open_or_stdin(command.certificate.as_deref())?; let cert = Cert::from_reader(input)?; let mut wanted: Vec<(KeyHandle, @@ -714,8 +718,10 @@ fn adopt(config: Config, command: KeyAdoptCommand) -> Result<()> { Ok(()) } -fn attest_certifications(config: Config, command: KeyAttestCertificationsCommand) - -> Result<()> { +fn attest_certifications( + config: Config, + command: sq_cli::key::AttestCertificationsCommand, +) -> Result<()> { // Attest to all certifications? let all = !command.none; // All is the default. diff --git a/sq/src/commands/keyring.rs b/sq/src/commands/keyring.rs index c707a5e0..88875550 100644 --- a/sq/src/commands/keyring.rs +++ b/sq/src/commands/keyring.rs @@ -33,10 +33,10 @@ use crate::{ output::KeyringListItem, }; -use crate::sq_cli::keyring::KeyringCommand; -use crate::sq_cli::keyring::KeyringSubcommands::*; +use crate::sq_cli::keyring; -pub fn dispatch(config: Config, c: KeyringCommand) -> Result<()> { +pub fn dispatch(config: Config, c: keyring::Command) -> Result<()> { + use crate::sq_cli::keyring::Subcommands::*; match c.subcommand { Filter(command) => { let any_uid_predicates = diff --git a/sq/src/commands/mod.rs b/sq/src/commands/mod.rs index d82b2dca..5a82a61f 100644 --- a/sq/src/commands/mod.rs +++ b/sq/src/commands/mod.rs @@ -36,9 +36,9 @@ use crate::{ Config, }; -use crate::sq_cli::encrypt::EncryptCompressionMode; -use crate::sq_cli::encrypt::EncryptEncryptionMode; -use crate::sq_cli::packet::PacketJoinCommand; +use crate::sq_cli::encrypt::CompressionMode; +use crate::sq_cli::encrypt::EncryptionMode; +use crate::sq_cli::packet; #[cfg(feature = "autocrypt")] pub mod autocrypt; @@ -313,8 +313,8 @@ pub struct EncryptOpts<'a> { pub npasswords: usize, pub recipients: &'a [openpgp::Cert], pub signers: Vec, - pub mode: EncryptEncryptionMode, - pub compression: EncryptCompressionMode, + pub mode: EncryptionMode, + pub compression: CompressionMode, pub time: Option, pub use_expired_subkey: bool, } @@ -337,13 +337,13 @@ pub fn encrypt(opts: EncryptOpts) -> Result<()> { } let mode = match opts.mode { - EncryptEncryptionMode::Rest => { + EncryptionMode::Rest => { KeyFlags::empty().set_storage_encryption() } - EncryptEncryptionMode::Transport => { + EncryptionMode::Transport => { KeyFlags::empty().set_transport_encryption() } - EncryptEncryptionMode::All => KeyFlags::empty() + EncryptionMode::All => KeyFlags::empty() .set_storage_encryption() .set_transport_encryption(), }; @@ -402,13 +402,13 @@ pub fn encrypt(opts: EncryptOpts) -> Result<()> { .context("Failed to create encryptor")?; match opts.compression { - EncryptCompressionMode::None => (), - EncryptCompressionMode::Pad => sink = Padder::new(sink).build()?, - EncryptCompressionMode::Zip => sink = + CompressionMode::None => (), + CompressionMode::Pad => sink = Padder::new(sink).build()?, + CompressionMode::Zip => sink = Compressor::new(sink).algo(CompressionAlgorithm::Zip).build()?, - EncryptCompressionMode::Zlib => sink = + CompressionMode::Zlib => sink = Compressor::new(sink).algo(CompressionAlgorithm::Zlib).build()?, - EncryptCompressionMode::Bzip2 => sink = + CompressionMode::Bzip2 => sink = Compressor::new(sink).algo(CompressionAlgorithm::BZip2).build()?, } @@ -683,7 +683,7 @@ pub fn split(input: &mut (dyn io::Read + Sync + Send), prefix: &str) } /// Joins the given files. -pub fn join(config: Config, c: PacketJoinCommand) -> Result<()> { +pub fn join(config: Config, c: packet::JoinCommand) -> Result<()> { // Either we know what kind of armor we want to produce, or we // need to detect it using the first packet we see. let kind = c.kind.into(); diff --git a/sq/src/commands/net.rs b/sq/src/commands/net.rs index 92c939fe..4b5e6b2e 100644 --- a/sq/src/commands/net.rs +++ b/sq/src/commands/net.rs @@ -30,12 +30,9 @@ use crate::{ output::WkdUrlVariant, }; -use crate::sq_cli::keyserver::KeyserverCommand; -use crate::sq_cli::keyserver::KeyserverSubcommands; -use crate::sq_cli::wkd::WkdCommand; -use crate::sq_cli::wkd::WkdSubcommands; +use crate::sq_cli; -pub fn dispatch_keyserver(config: Config, c: KeyserverCommand) -> Result<()> { +pub fn dispatch_keyserver(config: Config, c: sq_cli::keyserver::Command) -> Result<()> { let network_policy = c.network_policy.into(); let mut ks = if let Some(uri) = c.server { KeyServer::new(network_policy, &uri) @@ -48,8 +45,9 @@ pub fn dispatch_keyserver(config: Config, c: KeyserverCommand) -> Result<()> { .enable_time() .build()?; + use crate::sq_cli::keyserver::Subcommands::*; match c.subcommand { - KeyserverSubcommands::Get(c) => { + Get(c) => { let query = c.query; let handle = query.parse::(); @@ -78,7 +76,7 @@ pub fn dispatch_keyserver(config: Config, c: KeyserverCommand) -> Result<()> { or an email address: {:?}", query)); } }, - KeyserverSubcommands::Send(c) => { + Send(c) => { let mut input = open_or_stdin(c.input.as_deref())?; let cert = Cert::from_reader(&mut input). context("Malformed key")?; @@ -91,7 +89,7 @@ pub fn dispatch_keyserver(config: Config, c: KeyserverCommand) -> Result<()> { Ok(()) } -pub fn dispatch_wkd(config: Config, c: WkdCommand) -> Result<()> { +pub fn dispatch_wkd(config: Config, c: sq_cli::wkd::Command) -> Result<()> { let network_policy: net::Policy = c.network_policy.into(); let rt = tokio::runtime::Builder::new_current_thread() @@ -99,8 +97,9 @@ pub fn dispatch_wkd(config: Config, c: WkdCommand) -> Result<()> { .enable_time() .build()?; + use crate::sq_cli::wkd::Subcommands::*; match c.subcommand { - WkdSubcommands::Url(c) => { + Url(c) => { let wkd_url = wkd::Url::from(&c.email_address)?; let advanced = wkd_url.to_url(None)?.to_string(); let direct = wkd_url.to_url(wkd::Variant::Direct)?.to_string(); @@ -108,7 +107,7 @@ pub fn dispatch_wkd(config: Config, c: WkdCommand) -> Result<()> { WkdUrlVariant::Advanced, advanced, direct)?; output.write(config.output_format, &mut std::io::stdout())?; }, - WkdSubcommands::DirectUrl(c) => { + DirectUrl(c) => { let wkd_url = wkd::Url::from(&c.email_address)?; let advanced = wkd_url.to_url(None)?.to_string(); let direct = wkd_url.to_url(wkd::Variant::Direct)?.to_string(); @@ -116,7 +115,7 @@ pub fn dispatch_wkd(config: Config, c: WkdCommand) -> Result<()> { WkdUrlVariant::Direct, advanced, direct)?; output.write(config.output_format, &mut std::io::stdout())?; }, - WkdSubcommands::Get(c) => { + Get(c) => { // Check that the policy allows https. network_policy.assert(net::Policy::Encrypted)?; @@ -138,7 +137,7 @@ pub fn dispatch_wkd(config: Config, c: WkdCommand) -> Result<()> { config.create_or_stdout_safe(c.output.as_deref())?; serialize_keyring(&mut output, &certs, c.binary)?; }, - WkdSubcommands::Generate(c) => { + Generate(c) => { let domain = c.domain; let skip = c.skip; let f = open_or_stdin(c.input.as_deref())?; diff --git a/sq/src/commands/revoke.rs b/sq/src/commands/revoke.rs index dd530025..a4f3bbf3 100644 --- a/sq/src/commands/revoke.rs +++ b/sq/src/commands/revoke.rs @@ -44,22 +44,18 @@ impl RevocationTarget { } } -use crate::sq_cli::revoke::RevokeCommand; -use crate::sq_cli::revoke::RevokeSubcommands; -use crate::sq_cli::revoke::RevokeCertificateCommand; -use crate::sq_cli::revoke::RevokeSubkeyCommand; -use crate::sq_cli::revoke::RevokeUseridCommand; +use crate::sq_cli::revoke; -pub fn dispatch(config: Config, c: RevokeCommand) -> Result<()> { +pub fn dispatch(config: Config, c: revoke::Command) -> Result<()> { match c.subcommand { - RevokeSubcommands::Certificate(c) => revoke_certificate(config, c), - RevokeSubcommands::Subkey(c) => revoke_subkey(config, c), - RevokeSubcommands::Userid(c) => revoke_userid(config, c), + revoke::Subcommands::Certificate(c) => revoke_certificate(config, c), + revoke::Subcommands::Subkey(c) => revoke_subkey(config, c), + revoke::Subcommands::Userid(c) => revoke_userid(config, c), } } -pub fn revoke_certificate(config: Config, c: RevokeCertificateCommand) -> Result<()> { +pub fn revoke_certificate(config: Config, c: revoke::CertificateCommand) -> Result<()> { let revocation_target = RevocationTarget::Certificate; let cert = read_cert(c.input.as_deref())?; @@ -86,7 +82,7 @@ pub fn revoke_certificate(config: Config, c: RevokeCertificateCommand) -> Result Ok(()) } -pub fn revoke_subkey(config: Config, c: RevokeSubkeyCommand) -> Result<()> { +pub fn revoke_subkey(config: Config, c: revoke::SubkeyCommand) -> Result<()> { let revocation_target = { let kh: KeyHandle = c.subkey .parse() @@ -121,7 +117,7 @@ pub fn revoke_subkey(config: Config, c: RevokeSubkeyCommand) -> Result<()> { Ok(()) } -pub fn revoke_userid(config: Config, c: RevokeUseridCommand) -> Result<()> { +pub fn revoke_userid(config: Config, c: revoke::UseridCommand) -> Result<()> { let revocation_target = RevocationTarget::UserID(c.userid); let cert = read_cert(c.input.as_deref())?; diff --git a/sq/src/sq.rs b/sq/src/sq.rs index 48f7fe0b..db0a0c79 100644 --- a/sq/src/sq.rs +++ b/sq/src/sq.rs @@ -29,7 +29,7 @@ use crate::openpgp::cert::prelude::*; use crate::openpgp::policy::StandardPolicy as P; use clap::FromArgMatches; -use crate::sq_cli::packet::PacketSubcommands; +use crate::sq_cli::packet; use sq_cli::SqSubcommands; mod sq_cli; @@ -625,7 +625,7 @@ fn main() -> Result<()> { }, SqSubcommands::Packet(command) => match command.subcommand { - PacketSubcommands::Dump(command) => { + packet::Subcommands::Dump(command) => { let mut input = open_or_stdin(command.io.input.as_deref())?; let mut output = config.create_or_stdout_unsafe( command.io.output.as_deref(), @@ -638,7 +638,7 @@ fn main() -> Result<()> { session_key.as_ref(), width)?; }, - PacketSubcommands::Decrypt(command) => { + packet::Subcommands::Decrypt(command) => { let mut input = open_or_stdin(command.io.input.as_deref())?; let mut output = config.create_or_stdout_pgp( command.io.output.as_deref(), @@ -658,7 +658,7 @@ fn main() -> Result<()> { output.finalize()?; }, - PacketSubcommands::Split(command) => { + packet::Subcommands::Split(command) => { let mut input = open_or_stdin(command.input.as_deref())?; let prefix = // The prefix is either specified explicitly... @@ -675,7 +675,7 @@ fn main() -> Result<()> { + "-"); commands::split(&mut input, &prefix)?; }, - PacketSubcommands::Join(command) => commands::join(config, command)?, + packet::Subcommands::Join(command) => commands::join(config, command)?, }, SqSubcommands::Keyserver(command) => { diff --git a/sq/src/sq_cli/armor.rs b/sq/src/sq_cli/armor.rs index 8df72e6f..096f9b58 100644 --- a/sq/src/sq_cli/armor.rs +++ b/sq/src/sq_cli/armor.rs @@ -29,7 +29,7 @@ $ sq armor binary-juliet.pgp $ sq armor binary-message.pgp " )] -pub struct ArmorCommand { +pub struct Command { #[clap(flatten)] pub io: IoArgs, #[clap( diff --git a/sq/src/sq_cli/autocrypt.rs b/sq/src/sq_cli/autocrypt.rs index 8b37d08f..c6ec1817 100644 --- a/sq/src/sq_cli/autocrypt.rs +++ b/sq/src/sq_cli/autocrypt.rs @@ -18,16 +18,16 @@ See https://autocrypt.org/ subcommand_required = true, arg_required_else_help = true )] -pub struct AutocryptCommand { +pub struct Command { #[clap(subcommand)] - pub subcommand: AutocryptSubcommands, + pub subcommand: Subcommands, } #[derive(Debug, Subcommand)] -pub enum AutocryptSubcommands { - Decode(AutocryptDecodeCommand), +pub enum Subcommands { + Decode(DecodeCommand), - EncodeSender(AutocryptEncodeSenderCommand), + EncodeSender(EncodeSenderCommand), } #[derive(Debug, Args)] @@ -46,7 +46,7 @@ The converse operation is \"sq autocrypt encode-sender\". $ sq autocrypt decode autocrypt.eml " )] -pub struct AutocryptDecodeCommand { +pub struct DecodeCommand { #[clap(flatten)] pub io: IoArgs, #[clap(short = 'B', long, help = "Emits binary data")] @@ -80,7 +80,7 @@ $ sq autocrypt encode-sender --email juliet@example.org juliet.pgp $ sq autocrypt encode-sender --prefer-encrypt mutual juliet.pgp " )] -pub struct AutocryptEncodeSenderCommand { +pub struct EncodeSenderCommand { #[clap(flatten)] pub io: IoArgs, // TODO the help message looks like "primary userid" might be the default diff --git a/sq/src/sq_cli/certify.rs b/sq/src/sq_cli/certify.rs index e886d2cf..d00a752e 100644 --- a/sq/src/sq_cli/certify.rs +++ b/sq/src/sq_cli/certify.rs @@ -26,7 +26,7 @@ $ sq certify juliet.pgp romeo.pgp \"\" ", )] #[clap(group(ArgGroup::new("expiration-group").args(&["expires", "expires-in"])))] -pub struct CertifyCommand { +pub struct Command { #[clap( short, long, diff --git a/sq/src/sq_cli/dearmor.rs b/sq/src/sq_cli/dearmor.rs index 704681a0..8222eac7 100644 --- a/sq/src/sq_cli/dearmor.rs +++ b/sq/src/sq_cli/dearmor.rs @@ -27,7 +27,7 @@ $ sq dearmor ascii-juliet.pgp $ sq dearmor ascii-message.pgp ", )] -pub struct DearmorCommand { +pub struct Command { #[clap(flatten)] pub io: IoArgs, } diff --git a/sq/src/sq_cli/decrypt.rs b/sq/src/sq_cli/decrypt.rs index 5ccc6b7c..17efa836 100644 --- a/sq/src/sq_cli/decrypt.rs +++ b/sq/src/sq_cli/decrypt.rs @@ -41,7 +41,7 @@ $ sq decrypt ciphertext.pgp ", )] // TODO use usize -pub struct DecryptCommand { +pub struct Command { #[clap(flatten)] pub io: IoArgs, #[clap( diff --git a/sq/src/sq_cli/encrypt.rs b/sq/src/sq_cli/encrypt.rs index 1f31953f..dc4b4f20 100644 --- a/sq/src/sq_cli/encrypt.rs +++ b/sq/src/sq_cli/encrypt.rs @@ -27,7 +27,7 @@ $ sq encrypt --recipient-cert romeo.pgp --signer-key juliet.pgp message.txt $ sq encrypt --symmetric message.txt ", )] -pub struct EncryptCommand { +pub struct Command { #[clap(flatten)] pub io: IoArgs, #[clap( @@ -69,7 +69,7 @@ pub struct EncryptCommand { #[clap( long = "mode", value_name = "MODE", - default_value_t = EncryptEncryptionMode::All, + default_value_t = EncryptionMode::All, help = "Selects what kind of keys are considered for encryption.", long_help = "Selects what kind of keys are considered for \ @@ -80,15 +80,15 @@ pub struct EncryptCommand { subkeys.", arg_enum, )] - pub mode: EncryptEncryptionMode, + pub mode: EncryptionMode, #[clap( long = "compression", value_name = "KIND", - default_value_t = EncryptCompressionMode::Pad, + default_value_t = CompressionMode::Pad, help = "Selects compression scheme to use", arg_enum, )] - pub compression: EncryptCompressionMode, + pub compression: CompressionMode, #[clap( short = 't', long = "time", @@ -109,14 +109,14 @@ pub struct EncryptCommand { } #[derive(ArgEnum, Debug, Clone)] -pub enum EncryptEncryptionMode { +pub enum EncryptionMode { Transport, Rest, All } #[derive(ArgEnum, Debug, Clone)] -pub enum EncryptCompressionMode { +pub enum CompressionMode { None, Pad, Zip, diff --git a/sq/src/sq_cli/inspect.rs b/sq/src/sq_cli/inspect.rs index 0fceac24..af9e29ac 100644 --- a/sq/src/sq_cli/inspect.rs +++ b/sq/src/sq_cli/inspect.rs @@ -28,7 +28,7 @@ $ sq inspect message.pgp $ sq inspect message.sig ", )] -pub struct InspectCommand { +pub struct Command { #[clap( value_name = "FILE", help = "Reads from FILE or stdin if omitted", diff --git a/sq/src/sq_cli/key.rs b/sq/src/sq_cli/key.rs index 7b9f48c5..9d81a56d 100644 --- a/sq/src/sq_cli/key.rs +++ b/sq/src/sq_cli/key.rs @@ -21,20 +21,20 @@ operations on certificates. arg_required_else_help = true, setting(clap::AppSettings::DeriveDisplayOrder), )] -pub struct KeyCommand { +pub struct Command { #[clap(subcommand)] - pub subcommand: KeySubcommands, + pub subcommand: Subcommands, } #[derive(Debug, Subcommand)] -pub enum KeySubcommands { - Generate(KeyGenerateCommand), - Password(KeyPasswordCommand), +pub enum Subcommands { + Generate(GenerateCommand), + Password(PasswordCommand), #[clap(subcommand)] - Userid(KeyUseridCommand), - ExtractCert(KeyExtractCertCommand), - AttestCertifications(KeyAttestCertificationsCommand), - Adopt(KeyAdoptCommand), + Userid(UseridCommand), + ExtractCert(ExtractCertCommand), + AttestCertifications(AttestCertificationsCommand), + Adopt(AdoptCommand), } #[derive(Debug, Args)] @@ -76,7 +76,7 @@ $ sq key generate --userid \"\" --userid \"Juliet Capulet\" #[clap(group(ArgGroup::new("cap-sign").args(&["can-sign", "cannot-sign"])))] #[clap(group(ArgGroup::new("cap-authenticate").args(&["can-authenticate", "cannot-authenticate"])))] #[clap(group(ArgGroup::new("cap-encrypt").args(&["can-encrypt", "cannot-encrypt"])))] -pub struct KeyGenerateCommand { +pub struct GenerateCommand { #[clap( short = 'u', long = "userid", @@ -88,11 +88,11 @@ pub struct KeyGenerateCommand { short = 'c', long = "cipher-suite", value_name = "CIPHER-SUITE", - default_value_t = KeyCipherSuite::Cv25519, + default_value_t = CipherSuite::Cv25519, help = "Selects the cryptographic algorithms for the key", arg_enum, )] - pub cipher_suite: KeyCipherSuite, + pub cipher_suite: CipherSuite, #[clap( long = "with-password", help = "Protects the key with a password", @@ -171,7 +171,7 @@ $ sq key generate --creation-time 20110609T1938+0200 --export noam.pgp [default: universal]", arg_enum, )] - pub can_encrypt: Option, + pub can_encrypt: Option, #[clap( long = "cannot-encrypt", help = "Adds no encryption-capable subkey", @@ -200,14 +200,14 @@ $ sq key generate --creation-time 20110609T1938+0200 --export noam.pgp } #[derive(ArgEnum, Clone, Debug)] -pub enum KeyCipherSuite { +pub enum CipherSuite { Rsa3k, Rsa4k, Cv25519 } #[derive(ArgEnum, Clone, Debug)] -pub enum KeyEncryptPurpose { +pub enum EncryptPurpose { Transport, Storage, Universal @@ -239,7 +239,7 @@ $ sq key password < juliet.key.pgp > juliet.encrypted_key.pgp $ sq key password --clear < juliet.encrypted_key.pgp > juliet.decrypted_key.pgp ", )] -pub struct KeyPasswordCommand { +pub struct PasswordCommand { #[clap(flatten)] pub io: IoArgs, #[clap( @@ -276,7 +276,7 @@ $ sq key generate --userid \"\" --export juliet.key.pgp $ sq key extract-cert --output juliet.cert.pgp juliet.key.pgp ", )] -pub struct KeyExtractCertCommand { +pub struct ExtractCertCommand { #[clap(flatten)] pub io: IoArgs, #[clap( @@ -300,9 +300,9 @@ Add User IDs to, or strip User IDs from a key. arg_required_else_help = true, setting(clap::AppSettings::DeriveDisplayOrder), )] -pub enum KeyUseridCommand { - Add(KeyUseridAddCommand), - Strip(KeyUseridStripCommand), +pub enum UseridCommand { + Add(UseridAddCommand), + Strip(UseridStripCommand), } #[derive(Debug, Args)] @@ -326,7 +326,7 @@ $ sq key userid add --userid \"Juliet\" juliet.key.pgp \\ --output juliet-new.key.pgp ", )] -pub struct KeyUseridAddCommand { +pub struct UseridAddCommand { #[clap(flatten)] pub io: IoArgs, #[clap( @@ -408,7 +408,7 @@ $ sq key userid strip --userid \"\" \\ --output juliet-new.key.pgp juliet.key.pgp ", )] -pub struct KeyUseridStripCommand { +pub struct UseridStripCommand { #[clap(flatten)] pub io: IoArgs, #[clap( @@ -449,7 +449,7 @@ feasible. $ sq key adopt --keyring juliet-old.pgp --key 0123456789ABCDEF -- juliet-new.pgp ", )] -pub struct KeyAdoptCommand { +pub struct AdoptCommand { #[clap( short = 'r', long = "keyring", @@ -519,7 +519,7 @@ $ sq key attest-certifications juliet.pgp $ sq key attest-certifications --none juliet.pgp ", )] -pub struct KeyAttestCertificationsCommand { +pub struct AttestCertificationsCommand { #[clap( long = "none", conflicts_with = "all", diff --git a/sq/src/sq_cli/keyring.rs b/sq/src/sq_cli/keyring.rs index 0a12d8e1..510b23b5 100644 --- a/sq/src/sq_cli/keyring.rs +++ b/sq/src/sq_cli/keyring.rs @@ -19,18 +19,18 @@ terms keys and certs interchangeably. arg_required_else_help = true, setting(clap::AppSettings::DeriveDisplayOrder), )] -pub struct KeyringCommand { +pub struct Command { #[clap(subcommand)] - pub subcommand: KeyringSubcommands, + pub subcommand: Subcommands, } #[derive(Debug, Subcommand)] -pub enum KeyringSubcommands { - List(KeyringListCommand), - Split(KeyringSplitCommand), - Join(KeyringJoinCommand), - Merge(KeyringMergeCommand), - Filter(KeyringFilterCommand), +pub enum Subcommands { + List(ListCommand), + Split(SplitCommand), + Join(JoinCommand), + Merge(MergeCommand), + Filter(FilterCommand), } #[derive(Debug, Args)] @@ -74,7 +74,7 @@ $ sq keyring filter --domain example.org keys.pgp | \\ $ sq keyring filter --domain example.org --prune-certs certs.pgp ", )] -pub struct KeyringFilterCommand { +pub struct FilterCommand { #[clap(value_name = "FILE", help = "Reads from FILE or stdin if omitted")] pub input: Vec, #[clap( @@ -175,7 +175,7 @@ The converse operation is \"sq keyring split\". $ sq keyring join juliet.pgp romeo.pgp alice.pgp ", )] -pub struct KeyringJoinCommand { +pub struct JoinCommand { #[clap(value_name = "FILE", help = "Sets the input files to use")] pub input: Vec, #[clap( @@ -211,7 +211,7 @@ is preferred. $ sq keyring merge certs.pgp romeo-updates.pgp ", )] -pub struct KeyringMergeCommand { +pub struct MergeCommand { #[clap( value_name = "FILE", help = "Reads from FILE", @@ -251,7 +251,7 @@ $ sq keyring list certs.pgp $ sq keyring filter --domain example.org certs.pgp | sq keyring list ", )] -pub struct KeyringListCommand { +pub struct ListCommand { #[clap( value_name = "FILE", help = "Reads from FILE or stdin if omitted", @@ -288,7 +288,7 @@ $ sq keyring split certs.pgp $ sq keyring merge certs.pgp | sq keyring split ", )] -pub struct KeyringSplitCommand { +pub struct SplitCommand { #[clap( value_name = "FILE", help = "Reads from FILE or stdin if omitted", diff --git a/sq/src/sq_cli/keyserver.rs b/sq/src/sq_cli/keyserver.rs index 37d247ee..b5374b99 100644 --- a/sq/src/sq_cli/keyserver.rs +++ b/sq/src/sq_cli/keyserver.rs @@ -9,7 +9,7 @@ use super::NetworkPolicy; subcommand_required = true, arg_required_else_help = true, )] -pub struct KeyserverCommand { +pub struct Command { #[clap( short = 'p', long = "policy", @@ -27,20 +27,20 @@ pub struct KeyserverCommand { )] pub server: Option, #[clap(subcommand)] - pub subcommand: KeyserverSubcommands, + pub subcommand: Subcommands, } #[derive(Debug, Subcommand)] -pub enum KeyserverSubcommands { - Get(KeyserverGetCommand), - Send(KeyserverSendCommand), +pub enum Subcommands { + Get(GetCommand), + Send(SendCommand), } #[derive(Debug, Args)] #[clap( about = "Retrieves a key", )] -pub struct KeyserverGetCommand { +pub struct GetCommand { #[clap( short, long, @@ -67,7 +67,7 @@ pub struct KeyserverGetCommand { #[clap( about = "Sends a key", )] -pub struct KeyserverSendCommand { +pub struct SendCommand { #[clap(value_name = "FILE", help = "Reads from FILE or stdin if omitted")] pub input: Option, } diff --git a/sq/src/sq_cli/mod.rs b/sq/src/sq_cli/mod.rs index 2e29131c..acbceb13 100644 --- a/sq/src/sq_cli/mod.rs +++ b/sq/src/sq_cli/mod.rs @@ -119,30 +119,30 @@ pub struct SqCommand { /// The order is derived from the order of variants in this enum. #[derive(Debug, Subcommand)] pub enum SqSubcommands { - Encrypt(encrypt::EncryptCommand), - Decrypt(decrypt::DecryptCommand), + Encrypt(encrypt::Command), + Decrypt(decrypt::Command), - Sign(sign::SignCommand), - Verify(verify::VerifyCommand), + Sign(sign::Command), + Verify(verify::Command), - Key(key::KeyCommand), - Keyring(keyring::KeyringCommand), - Certify(certify::CertifyCommand), + Key(key::Command), + Keyring(keyring::Command), + Certify(certify::Command), #[cfg(feature = "autocrypt")] - Autocrypt(autocrypt::AutocryptCommand), - Keyserver(keyserver::KeyserverCommand), - Wkd(wkd::WkdCommand), + Autocrypt(autocrypt::Command), + Keyserver(keyserver::Command), + Wkd(wkd::Command), - Armor(armor::ArmorCommand), - Dearmor(dearmor::DearmorCommand), + Armor(armor::Command), + Dearmor(dearmor::Command), - Inspect(inspect::InspectCommand), - Packet(packet::PacketCommand), + Inspect(inspect::Command), + Packet(packet::Command), - Revoke(revoke::RevokeCommand), + Revoke(revoke::Command), - OutputVersions(output_versions::OutputVersionsCommand), + OutputVersions(output_versions::Command), } use chrono::{offset::Utc, DateTime}; diff --git a/sq/src/sq_cli/output_versions.rs b/sq/src/sq_cli/output_versions.rs index 6943943e..74211153 100644 --- a/sq/src/sq_cli/output_versions.rs +++ b/sq/src/sq_cli/output_versions.rs @@ -6,7 +6,7 @@ use clap::Parser; display_order = 110, about = "List supported output versions", )] -pub struct OutputVersionsCommand { +pub struct Command { /// List only the default output version. #[clap(long)] pub default: bool, diff --git a/sq/src/sq_cli/packet.rs b/sq/src/sq_cli/packet.rs index 0e523965..1672e613 100644 --- a/sq/src/sq_cli/packet.rs +++ b/sq/src/sq_cli/packet.rs @@ -19,17 +19,17 @@ as a learning tool. arg_required_else_help = true, setting(clap::AppSettings::DeriveDisplayOrder), )] -pub struct PacketCommand { +pub struct Command { #[clap(subcommand)] - pub subcommand: PacketSubcommands, + pub subcommand: Subcommands, } #[derive(Debug, Subcommand)] -pub enum PacketSubcommands { - Dump(PacketDumpCommand), - Decrypt(PacketDecryptCommand), - Split(PacketSplitCommand), - Join(PacketJoinCommand), +pub enum Subcommands { + Dump(DumpCommand), + Decrypt(DecryptCommand), + Split(SplitCommand), + Join(JoinCommand), } #[derive(Debug, Args)] @@ -62,7 +62,7 @@ $ sq packet dump --hex juliet.pgp $ sq packet dump --session-key AAAABBBBCCCC... ciphertext.pgp ", )] -pub struct PacketDumpCommand { +pub struct DumpCommand { #[clap(flatten)] pub io: IoArgs, #[clap( @@ -100,7 +100,7 @@ that can, among other things, be inspected using \"sq packet dump\". $ sq packet decrypt --recipient-key juliet.pgp ciphertext.pgp ", )] -pub struct PacketDecryptCommand { +pub struct DecryptCommand { #[clap(flatten)] pub io: IoArgs, #[clap( @@ -152,7 +152,7 @@ The converse operation is \"sq packet join\". $ sq packet split juliet.pgp ", )] -pub struct PacketSplitCommand { +pub struct SplitCommand { #[clap(value_name = "FILE", help = "Reads from FILE or stdin if omitted")] pub input: Option, #[clap( @@ -186,7 +186,7 @@ $ sq packet split juliet.pgp $ sq packet join juliet.pgp-[0-3]* ", )] -pub struct PacketJoinCommand { +pub struct JoinCommand { #[clap(value_name = "FILE", help = "Reads from FILE or stdin if omitted")] pub input: Vec, #[clap( diff --git a/sq/src/sq_cli/revoke.rs b/sq/src/sq_cli/revoke.rs index bfef2dfb..3ec26e14 100644 --- a/sq/src/sq_cli/revoke.rs +++ b/sq/src/sq_cli/revoke.rs @@ -46,16 +46,16 @@ $ sq revoke userid --time 20220101 --certificate juliet.pgp \\ arg_required_else_help = true, setting(clap::AppSettings::DeriveDisplayOrder), )] -pub struct RevokeCommand { +pub struct Command { #[clap(subcommand)] - pub subcommand: RevokeSubcommands, + pub subcommand: Subcommands, } #[derive(Debug, Subcommand)] -pub enum RevokeSubcommands { - Certificate(RevokeCertificateCommand), - Subkey(RevokeSubkeyCommand), - Userid(RevokeUseridCommand), +pub enum Subcommands { + Certificate(CertificateCommand), + Subkey(SubkeyCommand), + Userid(UseridCommand), } #[derive(Debug, Args)] @@ -76,7 +76,7 @@ If \"--revocation-key\" is not provided, then the certificate must include a certification-capable key. ", )] -pub struct RevokeCertificateCommand { +pub struct CertificateCommand { #[clap( value_name = "FILE", long = "certificate", @@ -222,7 +222,7 @@ designated revoker. If \"--revocation-key\" is not provided, then the certificate must \ include a certification-capable key.", )] -pub struct RevokeSubkeyCommand { +pub struct SubkeyCommand { #[clap( value_name = "FILE", long = "certificate", @@ -355,7 +355,7 @@ designated revoker. If \"--revocation-key\" is not provided, then the certificate must \ include a certification-capable key.", )] -pub struct RevokeUseridCommand { +pub struct UseridCommand { #[clap( value_name = "FILE", long = "certificate", diff --git a/sq/src/sq_cli/sign.rs b/sq/src/sq_cli/sign.rs index c5e66880..5086c94f 100644 --- a/sq/src/sq_cli/sign.rs +++ b/sq/src/sq_cli/sign.rs @@ -24,7 +24,7 @@ $ sq sign --signer-key juliet.pgp message.txt $ sq sign --detached --signer-key juliet.pgp message.txt ", )] -pub struct SignCommand { +pub struct Command { #[clap(flatten)] pub io: IoArgs, // TODO: Why capital B? diff --git a/sq/src/sq_cli/verify.rs b/sq/src/sq_cli/verify.rs index 2c77d758..2f56a30d 100644 --- a/sq/src/sq_cli/verify.rs +++ b/sq/src/sq_cli/verify.rs @@ -39,7 +39,7 @@ If you are looking for a standalone program to verify detached signatures, consider using sequoia-sqv. ", )] -pub struct VerifyCommand { +pub struct Command { #[clap(flatten)] pub io: IoArgs, #[clap( diff --git a/sq/src/sq_cli/wkd.rs b/sq/src/sq_cli/wkd.rs index 1ccd6ad1..b90d4b0c 100644 --- a/sq/src/sq_cli/wkd.rs +++ b/sq/src/sq_cli/wkd.rs @@ -10,7 +10,7 @@ use super::NetworkPolicy; arg_required_else_help = true, setting(clap::AppSettings::DeriveDisplayOrder), )] -pub struct WkdCommand { +pub struct Command { #[clap( short, long, @@ -21,22 +21,22 @@ pub struct WkdCommand { )] pub network_policy: NetworkPolicy, #[clap(subcommand)] - pub subcommand: WkdSubcommands, + pub subcommand: Subcommands, } #[derive(Debug, Subcommand)] -pub enum WkdSubcommands { - Generate(WkdGenerateCommand), - Get(WkdGetCommand), - DirectUrl(WkdDirectUrlCommand), - Url(WkdUrlCommand), +pub enum Subcommands { + Generate(GenerateCommand), + Get(GetCommand), + DirectUrl(DirectUrlCommand), + Url(UrlCommand), } #[derive(Debug, Args)] #[clap( about = "Prints the advanced Web Key Directory URL of an email address.", )] -pub struct WkdUrlCommand { +pub struct UrlCommand { #[clap( value_name = "ADDRESS", help = "Queries for ADDRESS", @@ -48,7 +48,7 @@ pub struct WkdUrlCommand { #[clap( about = "Prints the direct Web Key Directory URL of an email address.", )] -pub struct WkdDirectUrlCommand { +pub struct DirectUrlCommand { #[clap( value_name = "ADDRESS", help = "Queries for ADDRESS", @@ -60,7 +60,7 @@ pub struct WkdDirectUrlCommand { #[clap( about = "Queries for certs using Web Key Directory", )] -pub struct WkdGetCommand { +pub struct GetCommand { #[clap( value_name = "ADDRESS", help = "Queries a cert for ADDRESS", @@ -108,7 +108,7 @@ for the direct version. sq does not copy files to the web server.", $ sq wkd generate /tmp/wkdroot example.com certs.ppg ", )] -pub struct WkdGenerateCommand { +pub struct GenerateCommand { #[clap( value_name = "WEB-ROOT", help = "Writes the WKD to WEB-ROOT", -- cgit v1.2.3