Remove sq network wkd url and direct-url.
- These leak implementation details and support the idea that WKD is just a http request to some URL, which is not true, and will be less true in the future. I don't think this is an interface that we can support going forward.
This commit is contained in:
parent
55f6fa894b
commit
f3f013fc9d
@ -33,32 +33,6 @@ pub struct Command {
|
||||
pub enum Subcommands {
|
||||
Fetch(FetchCommand),
|
||||
Publish(PublishCommand),
|
||||
DirectUrl(DirectUrlCommand),
|
||||
Url(UrlCommand),
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
#[clap(
|
||||
about = "Print the advanced Web Key Directory URL of an email address",
|
||||
)]
|
||||
pub struct UrlCommand {
|
||||
#[clap(
|
||||
value_name = "ADDRESS",
|
||||
help = "Query for ADDRESS",
|
||||
)]
|
||||
pub email_address: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
#[clap(
|
||||
about = "Print the direct Web Key Directory URL of an email address",
|
||||
)]
|
||||
pub struct DirectUrlCommand {
|
||||
#[clap(
|
||||
value_name = "ADDRESS",
|
||||
help = "Query for ADDRESS",
|
||||
)]
|
||||
pub email_address: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
|
@ -52,10 +52,8 @@ use crate::{
|
||||
pluralize::Pluralize,
|
||||
},
|
||||
Sq,
|
||||
Model,
|
||||
merge_keyring,
|
||||
serialize_keyring,
|
||||
output::WkdUrlVariant,
|
||||
print_error_chain,
|
||||
utils::cert_exportable,
|
||||
};
|
||||
@ -983,22 +981,6 @@ pub fn dispatch_wkd(mut sq: Sq, c: cli::network::wkd::Command)
|
||||
|
||||
use crate::cli::network::wkd::Subcommands::*;
|
||||
match c.subcommand {
|
||||
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();
|
||||
let output = Model::wkd_url(sq.output_version,
|
||||
WkdUrlVariant::Advanced, advanced, direct)?;
|
||||
output.write(sq.output_format, &mut std::io::stdout())?;
|
||||
},
|
||||
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();
|
||||
let output = Model::wkd_url(sq.output_version,
|
||||
WkdUrlVariant::Direct, advanced, direct)?;
|
||||
output.write(sq.output_format, &mut std::io::stdout())?;
|
||||
},
|
||||
Fetch(c) => rt.block_on(async {
|
||||
let mut pb = Response::progress_bar(&sq);
|
||||
let http_client = http_client()?;
|
||||
|
@ -50,7 +50,7 @@ use cli::output::{OutputFormat, OutputVersion};
|
||||
|
||||
mod commands;
|
||||
pub mod output;
|
||||
pub use output::{wkd::WkdUrlVariant, Model};
|
||||
pub use output::Model;
|
||||
|
||||
/// Converts sequoia_openpgp types for rendering.
|
||||
pub trait Convert<T> {
|
||||
|
@ -13,7 +13,6 @@ pub mod sanitize;
|
||||
pub mod wrapping;
|
||||
|
||||
pub use keyring::ListItem as KeyringListItem;
|
||||
pub use wkd::WkdUrlVariant;
|
||||
|
||||
use crate::cli::output::{OutputFormat, OutputVersion};
|
||||
|
||||
@ -30,7 +29,6 @@ pub const OUTPUT_VERSIONS: &[OutputVersion] = &[OutputVersion::new(0, 0, 0)];
|
||||
/// Each variant is created by a dedicated function.
|
||||
pub enum Model {
|
||||
KeyringListV0(keyring::ListV0),
|
||||
WkdUrlV0(wkd::UrlV0),
|
||||
}
|
||||
|
||||
impl Model {
|
||||
@ -39,20 +37,6 @@ impl Model {
|
||||
v.unwrap_or(DEFAULT_OUTPUT_VERSION)
|
||||
}
|
||||
|
||||
/// Create a model for the output of `sq wkd url` and `sq wkd
|
||||
/// direct-url` subcommands.
|
||||
pub fn wkd_url(version: Option<OutputVersion>,
|
||||
variant: wkd::WkdUrlVariant,
|
||||
advanced_url: String,
|
||||
direct_url: String) -> Result<Self> {
|
||||
let version = Self::version(version);
|
||||
let result = match version {
|
||||
wkd::UrlV0::V => Self::WkdUrlV0(wkd::UrlV0::new(variant, advanced_url, direct_url)),
|
||||
_ => return Err(anyhow!("unknown output version {:?}", version)),
|
||||
};
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Create a model for the output of the `sq toolbox keyring list`
|
||||
/// subcommand.
|
||||
pub fn keyring_list(version: Option<OutputVersion>, certs: Vec<keyring::ListItem>, all_uids: bool) -> Result<Self> {
|
||||
@ -74,12 +58,6 @@ impl Model {
|
||||
_ => x.human_readable(w)?,
|
||||
}
|
||||
}
|
||||
Self::WkdUrlV0(x) => {
|
||||
match format {
|
||||
OutputFormat::Json => x.json(w)?,
|
||||
_ => x.human_readable(w)?,
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -237,49 +215,3 @@ mod keyring {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Model output as a data type that can be serialized.
|
||||
pub mod wkd {
|
||||
use super::{OutputVersion, Result, Write};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum WkdUrlVariant {
|
||||
Advanced,
|
||||
Direct,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct UrlV0 {
|
||||
#[serde(skip)]
|
||||
variant: WkdUrlVariant,
|
||||
sq_output_version: OutputVersion,
|
||||
advanced_url: String,
|
||||
direct_url: String,
|
||||
}
|
||||
|
||||
impl UrlV0 {
|
||||
pub const V: OutputVersion = OutputVersion::new(0, 0, 0);
|
||||
|
||||
pub fn new(variant: WkdUrlVariant, advanced_url: String, direct_url: String) -> Self {
|
||||
Self {
|
||||
sq_output_version: Self::V,
|
||||
variant,
|
||||
advanced_url,
|
||||
direct_url,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn human_readable(&self, w: &mut dyn Write) -> Result<()> {
|
||||
match self.variant {
|
||||
WkdUrlVariant::Advanced => writeln!(w, "{}", self.advanced_url)?,
|
||||
WkdUrlVariant::Direct => writeln!(w, "{}", self.direct_url)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn json(&self, w: &mut dyn Write) -> Result<()> {
|
||||
super::to_json(w, self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user