use clap::Parser; use kittybox::webmentions::check::{check_mention, Error as WebmentionError}; #[derive(Debug, thiserror::Error)] enum Error { #[error("reqwest error: {0}")] Http(#[from] reqwest::Error), #[error("webmention check error: {0}")] Webmention(#[from] WebmentionError) } #[derive(Parser, Debug)] #[clap( name = "kittybox-check-webmention", author = "Vika ", version = env!("CARGO_PKG_VERSION"), about = "Verify an incoming webmention" )] struct Args { #[clap(value_parser)] url: url::Url, #[clap(value_parser)] link: url::Url } #[tokio::main] async fn main() -> Result<(), Error> { let args = Args::parse(); let http: reqwest::Client = { #[allow(unused_mut)] let mut builder = reqwest::Client::builder() .user_agent(concat!( env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION") )); builder.build().unwrap() }; let response = http.get(args.url.clone()).send().await?; let text = response.text().await?; if let Some(mention_type) = check_mention(text, &args.url, &args.link)? { println!("{:?}", mention_type); Ok(()) } else { std::process::exit(1) } }