From 607091724311bbb8f8728e98b0649d20f6bfd52f Mon Sep 17 00:00:00 2001 From: mountaincoding <86009219+mountaincoding@users.noreply.github.com> Date: Mon, 30 Nov 2026 14:28:59 -0700 Subject: [PATCH 1/2] style: apply Rust 2024 formatting --- src/client.rs | 3 +-- src/commands/automotive.rs | 12 +++--------- src/commands/cadastre.rs | 4 +--- src/commands/chamber_of_commerce.rs | 8 ++------ src/commands/company.rs | 20 +++++-------------- src/commands/domains.rs | 8 ++------ src/commands/massive_rem.rs | 4 +--- src/commands/mod.rs | 28 +++++++++++++-------------- src/commands/oauthv2.rs | 28 +++++++++++++++++++++------ src/commands/paying_bills.rs | 4 +--- src/commands/risk.rs | 8 ++------ src/commands/sdi.rs | 8 ++------ src/commands/token.rs | 4 +++- src/commands/trust.rs | 30 +++++++++++++++++++++++------ src/commands/visengine.rs | 8 ++------ src/commands/zip_codes.rs | 4 +--- src/config.rs | 7 +++---- src/scopes.rs | 13 +++++++++++-- 18 files changed, 100 insertions(+), 101 deletions(-) diff --git a/src/client.rs b/src/client.rs index f8cc1eb..345b802 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION, CONTENT_TYPE}; +use reqwest::header::{AUTHORIZATION, CONTENT_TYPE, HeaderMap, HeaderValue}; use serde_json::Value; use crate::config::{Config, OAuthConfig}; @@ -53,7 +53,6 @@ impl ApiClient { } Ok(body) } - } /// HTTP client for the OAuth management API (Basic auth). diff --git a/src/commands/automotive.rs b/src/commands/automotive.rs index ce9c6e0..39f2ffe 100644 --- a/src/commands/automotive.rs +++ b/src/commands/automotive.rs @@ -38,15 +38,11 @@ pub async fn execute(cmd: &AutomotiveCommands, client: &ApiClient) -> Result<()> let base = client.base_url(PROD, SANDBOX); match cmd { AutomotiveCommands::Car { plate } => { - let resp = client - .get(&format!("{}/IT-car/{}", base, plate)) - .await?; + let resp = client.get(&format!("{}/IT-car/{}", base, plate)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } AutomotiveCommands::Bike { plate } => { - let resp = client - .get(&format!("{}/IT-bike/{}", base, plate)) - .await?; + let resp = client.get(&format!("{}/IT-bike/{}", base, plate)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } AutomotiveCommands::Insurance { plate } => { @@ -56,9 +52,7 @@ pub async fn execute(cmd: &AutomotiveCommands, client: &ApiClient) -> Result<()> println!("{}", serde_json::to_string_pretty(&resp)?); } AutomotiveCommands::CheckId { id } => { - let resp = client - .get(&format!("{}/check_id/{}", base, id)) - .await?; + let resp = client.get(&format!("{}/check_id/{}", base, id)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } } diff --git a/src/commands/cadastre.rs b/src/commands/cadastre.rs index 8f28019..7b646bf 100644 --- a/src/commands/cadastre.rs +++ b/src/commands/cadastre.rs @@ -56,9 +56,7 @@ pub async fn execute(cmd: &CadastreCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } CadastreCommands::VisuraCatastale => { - let resp = client - .get(&format!("{}/visura_catastale", base)) - .await?; + let resp = client.get(&format!("{}/visura_catastale", base)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } CadastreCommands::GetVisuraCatastale { id } => { diff --git a/src/commands/chamber_of_commerce.rs b/src/commands/chamber_of_commerce.rs index 93f11da..c13f6b0 100644 --- a/src/commands/chamber_of_commerce.rs +++ b/src/commands/chamber_of_commerce.rs @@ -38,9 +38,7 @@ pub async fn execute(cmd: &ChamberOfCommerceCommands, client: &ApiClient) -> Res println!("{}", serde_json::to_string_pretty(&resp)?); } ChamberOfCommerceCommands::Get { code } => { - let resp = client - .get(&format!("{}/impresa/{}", base, code)) - .await?; + let resp = client.get(&format!("{}/impresa/{}", base, code)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } ChamberOfCommerceCommands::OrdinariaImpresaIndividuale => { @@ -56,9 +54,7 @@ pub async fn execute(cmd: &ChamberOfCommerceCommands, client: &ApiClient) -> Res println!("{}", serde_json::to_string_pretty(&resp)?); } ChamberOfCommerceCommands::SociAttivi => { - let resp = client - .get(&format!("{}/soci-attivi", base)) - .await?; + let resp = client.get(&format!("{}/soci-attivi", base)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } } diff --git a/src/commands/company.rs b/src/commands/company.rs index 3d755be..2789e4e 100644 --- a/src/commands/company.rs +++ b/src/commands/company.rs @@ -64,9 +64,7 @@ pub async fn execute(cmd: &CompanyCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } CompanyCommands::Start { code } => { - let resp = client - .get(&format!("{}/IT-start/{}", base, code)) - .await?; + let resp = client.get(&format!("{}/IT-start/{}", base, code)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } CompanyCommands::Advanced { code } => { @@ -76,9 +74,7 @@ pub async fn execute(cmd: &CompanyCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } CompanyCommands::Pec { code } => { - let resp = client - .get(&format!("{}/IT-pec/{}", base, code)) - .await?; + let resp = client.get(&format!("{}/IT-pec/{}", base, code)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } CompanyCommands::Shareholders { code } => { @@ -88,21 +84,15 @@ pub async fn execute(cmd: &CompanyCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } CompanyCommands::Address { code } => { - let resp = client - .get(&format!("{}/IT-address/{}", base, code)) - .await?; + let resp = client.get(&format!("{}/IT-address/{}", base, code)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } CompanyCommands::Sdicode { code } => { - let resp = client - .get(&format!("{}/IT-sdicode/{}", base, code)) - .await?; + let resp = client.get(&format!("{}/IT-sdicode/{}", base, code)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } CompanyCommands::Legalforms => { - let resp = client - .get(&format!("{}/IT-legalforms", base)) - .await?; + let resp = client.get(&format!("{}/IT-legalforms", base)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } } diff --git a/src/commands/domains.rs b/src/commands/domains.rs index 0bcf55b..708356b 100644 --- a/src/commands/domains.rs +++ b/src/commands/domains.rs @@ -30,9 +30,7 @@ pub async fn execute(cmd: &DomainsCommands, client: &ApiClient) -> Result<()> { let base = client.base_url(PROD, SANDBOX); match cmd { DomainsCommands::Check { domain } => { - let resp = client - .get(&format!("{}/check/{}", base, domain)) - .await?; + let resp = client.get(&format!("{}/check/{}", base, domain)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } DomainsCommands::List => { @@ -40,9 +38,7 @@ pub async fn execute(cmd: &DomainsCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } DomainsCommands::Get { domain } => { - let resp = client - .get(&format!("{}/domain/{}", base, domain)) - .await?; + let resp = client.get(&format!("{}/domain/{}", base, domain)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } DomainsCommands::Contacts => { diff --git a/src/commands/massive_rem.rs b/src/commands/massive_rem.rs index 0d43bfa..31234b0 100644 --- a/src/commands/massive_rem.rs +++ b/src/commands/massive_rem.rs @@ -80,9 +80,7 @@ pub async fn execute(cmd: &MassiveRemCommands, client: &ApiClient) -> Result<()> println!("{}", serde_json::to_string_pretty(&resp)?); } MassiveRemCommands::Quota { mailbox } => { - let resp = client - .get(&format!("{}/quota/{}", base, mailbox)) - .await?; + let resp = client.get(&format!("{}/quota/{}", base, mailbox)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } } diff --git a/src/commands/mod.rs b/src/commands/mod.rs index b37b8d9..8352df3 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,27 +1,27 @@ -pub mod token; -pub mod oauthv2; -pub mod esignature; pub mod ai; -pub mod sms; -pub mod trust; -pub mod exchange_rate; -pub mod risk; pub mod automotive; -pub mod sdi; -pub mod time_stamping; -pub mod real_estate; pub mod cadastre; pub mod certified_email; +pub mod chamber_of_commerce; +pub mod company; +pub mod docuengine; pub mod domains; +pub mod esignature; +pub mod exchange_rate; pub mod geocoding; -pub mod invoice; pub mod info; +pub mod invoice; pub mod massive_rem; +pub mod oauthv2; pub mod paying_bills; pub mod pdf; pub mod postal_service; -pub mod company; -pub mod chamber_of_commerce; -pub mod docuengine; +pub mod real_estate; +pub mod risk; +pub mod sdi; +pub mod sms; +pub mod time_stamping; +pub mod token; +pub mod trust; pub mod visengine; pub mod zip_codes; diff --git a/src/commands/oauthv2.rs b/src/commands/oauthv2.rs index 990cf84..797f13f 100644 --- a/src/commands/oauthv2.rs +++ b/src/commands/oauthv2.rs @@ -1,6 +1,6 @@ use anyhow::Result; use clap::Subcommand; -use serde_json::{json, Map, Value}; +use serde_json::{Map, Value, json}; use crate::client::OAuthV2Client; use crate::scopes; @@ -260,7 +260,9 @@ pub async fn execute(cmd: &Oauthv2Commands, client: &OAuthV2Client) -> Result<() body.insert("limits".to_string(), limits); } - let resp = client.post(&format!("{}/tokens", base), &Value::Object(body)).await?; + let resp = client + .post(&format!("{}/tokens", base), &Value::Object(body)) + .await?; print_json(&resp)?; } Oauthv2TokenCommands::List { limit, skip } => { @@ -336,7 +338,11 @@ pub async fn execute(cmd: &Oauthv2Commands, client: &OAuthV2Client) -> Result<() } }, Oauthv2Commands::Errors { command } => match command { - Oauthv2ErrorCommands::List { scopes, limit, skip } => { + Oauthv2ErrorCommands::List { + scopes, + limit, + skip, + } => { let mut params = pagination_params(*limit, *skip); push_optional(&mut params, "scopes", scopes.clone()); let resp = client @@ -362,7 +368,9 @@ pub async fn execute(cmd: &Oauthv2Commands, client: &OAuthV2Client) -> Result<() Oauthv2StatsCommands::Overview { date } => { let mut params = Vec::new(); push_optional(&mut params, "date", date.clone()); - let resp = client.get_query(&format!("{}/stats", base), ¶ms).await?; + let resp = client + .get_query(&format!("{}/stats", base), ¶ms) + .await?; print_json(&resp)?; } Oauthv2StatsCommands::Apis { date } => { @@ -391,7 +399,11 @@ pub async fn execute(cmd: &Oauthv2Commands, client: &OAuthV2Client) -> Result<() } }, Oauthv2Commands::Subscriptions { command } => match command { - Oauthv2SubscriptionCommands::List { scopes, limit, skip } => { + Oauthv2SubscriptionCommands::List { + scopes, + limit, + skip, + } => { let mut params = pagination_params(*limit, *skip); push_optional(&mut params, "scopes", scopes.clone()); let resp = client @@ -407,7 +419,11 @@ pub async fn execute(cmd: &Oauthv2Commands, client: &OAuthV2Client) -> Result<() } }, Oauthv2Commands::Callbacks { command } => match command { - Oauthv2CallbackCommands::List { scopes, limit, skip } => { + Oauthv2CallbackCommands::List { + scopes, + limit, + skip, + } => { let mut params = pagination_params(*limit, *skip); push_optional(&mut params, "scopes", scopes.clone()); let resp = client diff --git a/src/commands/paying_bills.rs b/src/commands/paying_bills.rs index 3b47566..0bceadd 100644 --- a/src/commands/paying_bills.rs +++ b/src/commands/paying_bills.rs @@ -36,9 +36,7 @@ pub async fn execute(cmd: &PayingBillsCommands, client: &ApiClient) -> Result<() println!("{}", serde_json::to_string_pretty(&resp)?); } PayingBillsCommands::Receipt { id } => { - let resp = client - .get(&format!("{}/pay/{}/ricevuta", base, id)) - .await?; + let resp = client.get(&format!("{}/pay/{}/ricevuta", base, id)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } } diff --git a/src/commands/risk.rs b/src/commands/risk.rs index 50dc163..6a39492 100644 --- a/src/commands/risk.rs +++ b/src/commands/risk.rs @@ -66,9 +66,7 @@ pub async fn execute(cmd: &RiskCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } RiskCommands::ReportPersona => { - let resp = client - .get(&format!("{}/IT-report-persona", base)) - .await?; + let resp = client.get(&format!("{}/IT-report-persona", base)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } RiskCommands::GetReportPersona { id } => { @@ -78,9 +76,7 @@ pub async fn execute(cmd: &RiskCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } RiskCommands::ReportAzienda => { - let resp = client - .get(&format!("{}/IT-report-azienda", base)) - .await?; + let resp = client.get(&format!("{}/IT-report-azienda", base)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } RiskCommands::GetReportAzienda { id } => { diff --git a/src/commands/sdi.rs b/src/commands/sdi.rs index b4e1ab9..2432951 100644 --- a/src/commands/sdi.rs +++ b/src/commands/sdi.rs @@ -42,9 +42,7 @@ pub async fn execute(cmd: &SdiCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } SdiCommands::Get { uuid } => { - let resp = client - .get(&format!("{}/invoices/{}", base, uuid)) - .await?; + let resp = client.get(&format!("{}/invoices/{}", base, uuid)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } SdiCommands::Download { uuid } => { @@ -66,9 +64,7 @@ pub async fn execute(cmd: &SdiCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } SdiCommands::ApiConfigurations => { - let resp = client - .get(&format!("{}/api_configurations", base)) - .await?; + let resp = client.get(&format!("{}/api_configurations", base)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } } diff --git a/src/commands/token.rs b/src/commands/token.rs index 59be6e4..94cb681 100644 --- a/src/commands/token.rs +++ b/src/commands/token.rs @@ -30,7 +30,9 @@ pub enum TokenCommands { pub async fn execute(cmd: &TokenCommands, client: &OAuthClient) -> Result<()> { let base = client.base_url(); match cmd { - TokenCommands::Create { scopes: scopes_input } => { + TokenCommands::Create { + scopes: scopes_input, + } => { // Fetch all available scopes to expand aliases let all_scopes = fetch_all_scopes(client).await?; let expanded = scopes::expand_aliases(scopes_input, &all_scopes, client.sandbox); diff --git a/src/commands/trust.rs b/src/commands/trust.rs index 28c13ff..909fa3e 100644 --- a/src/commands/trust.rs +++ b/src/commands/trust.rs @@ -51,37 +51,55 @@ pub async fn execute(cmd: &TrustCommands, client: &ApiClient) -> Result<()> { match cmd { TrustCommands::MobileStart { phone } => { let resp = client - .post(&format!("{}/mobile-start/{}", base, phone), &serde_json::json!({})) + .post( + &format!("{}/mobile-start/{}", base, phone), + &serde_json::json!({}), + ) .await?; println!("{}", serde_json::to_string_pretty(&resp)?); } TrustCommands::EmailStart { email } => { let resp = client - .post(&format!("{}/email-start/{}", base, email), &serde_json::json!({})) + .post( + &format!("{}/email-start/{}", base, email), + &serde_json::json!({}), + ) .await?; println!("{}", serde_json::to_string_pretty(&resp)?); } TrustCommands::MobileAdvanced { phone } => { let resp = client - .post(&format!("{}/mobile-advanced/{}", base, phone), &serde_json::json!({})) + .post( + &format!("{}/mobile-advanced/{}", base, phone), + &serde_json::json!({}), + ) .await?; println!("{}", serde_json::to_string_pretty(&resp)?); } TrustCommands::EmailAdvanced { email } => { let resp = client - .post(&format!("{}/email-advanced/{}", base, email), &serde_json::json!({})) + .post( + &format!("{}/email-advanced/{}", base, email), + &serde_json::json!({}), + ) .await?; println!("{}", serde_json::to_string_pretty(&resp)?); } TrustCommands::IpAdvanced { ip } => { let resp = client - .post(&format!("{}/ip-advanced/{}", base, ip), &serde_json::json!({})) + .post( + &format!("{}/ip-advanced/{}", base, ip), + &serde_json::json!({}), + ) .await?; println!("{}", serde_json::to_string_pretty(&resp)?); } TrustCommands::UrlAdvanced { url } => { let resp = client - .post(&format!("{}/url-advanced/{}", base, url), &serde_json::json!({})) + .post( + &format!("{}/url-advanced/{}", base, url), + &serde_json::json!({}), + ) .await?; println!("{}", serde_json::to_string_pretty(&resp)?); } diff --git a/src/commands/visengine.rs b/src/commands/visengine.rs index ffa02fd..1de309d 100644 --- a/src/commands/visengine.rs +++ b/src/commands/visengine.rs @@ -40,9 +40,7 @@ pub async fn execute(cmd: &VisengineCommands, client: &ApiClient) -> Result<()> println!("{}", serde_json::to_string_pretty(&resp)?); } VisengineCommands::VisuraDetails { hash } => { - let resp = client - .get(&format!("{}/visure/{}", base, hash)) - .await?; + let resp = client.get(&format!("{}/visure/{}", base, hash)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } VisengineCommands::Requests => { @@ -54,9 +52,7 @@ pub async fn execute(cmd: &VisengineCommands, client: &ApiClient) -> Result<()> println!("{}", serde_json::to_string_pretty(&resp)?); } VisengineCommands::Document { id } => { - let resp = client - .get(&format!("{}/documento/{}", base, id)) - .await?; + let resp = client.get(&format!("{}/documento/{}", base, id)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } } diff --git a/src/commands/zip_codes.rs b/src/commands/zip_codes.rs index 0faa342..7eeb7c3 100644 --- a/src/commands/zip_codes.rs +++ b/src/commands/zip_codes.rs @@ -66,9 +66,7 @@ pub async fn execute(cmd: &ZipCodesCommands, client: &ApiClient) -> Result<()> { println!("{}", serde_json::to_string_pretty(&resp)?); } ZipCodesCommands::Province { code } => { - let resp = client - .get(&format!("{}/province/{}", base, code)) - .await?; + let resp = client.get(&format!("{}/province/{}", base, code)).await?; println!("{}", serde_json::to_string_pretty(&resp)?); } } diff --git a/src/config.rs b/src/config.rs index 4b5a2ae..f43044d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; /// Config for service API commands (Bearer auth with OPENAPI_TOKEN). #[derive(Debug, Clone)] @@ -40,9 +40,8 @@ impl OAuthConfig { .map_err(|_| anyhow::anyhow!("OPENAPI_USERNAME environment variable not set"))?; let key = if sandbox { - std::env::var("OPENAPI_SANDBOX_KEY").map_err(|_| { - anyhow::anyhow!("OPENAPI_SANDBOX_KEY environment variable not set") - })? + std::env::var("OPENAPI_SANDBOX_KEY") + .map_err(|_| anyhow::anyhow!("OPENAPI_SANDBOX_KEY environment variable not set"))? } else { std::env::var("OPENAPI_KEY") .map_err(|_| anyhow::anyhow!("OPENAPI_KEY environment variable not set"))? diff --git a/src/scopes.rs b/src/scopes.rs index 95ee0cb..7d7d150 100644 --- a/src/scopes.rs +++ b/src/scopes.rs @@ -157,14 +157,23 @@ pub fn group_scopes_by_service(scopes: &[String], sandbox: bool) -> String { for alias in &aliases { let scopes = &grouped[alias]; - output.push_str(&format!(" {} ({} scope{})\n", alias, scopes.len(), if scopes.len() == 1 { "" } else { "s" })); + output.push_str(&format!( + " {} ({} scope{})\n", + alias, + scopes.len(), + if scopes.len() == 1 { "" } else { "s" } + )); for s in scopes { output.push_str(&format!(" {}\n", s)); } } if !unmatched.is_empty() { - output.push_str(&format!(" other ({} scope{})\n", unmatched.len(), if unmatched.len() == 1 { "" } else { "s" })); + output.push_str(&format!( + " other ({} scope{})\n", + unmatched.len(), + if unmatched.len() == 1 { "" } else { "s" } + )); for s in &unmatched { output.push_str(&format!(" {}\n", s)); } From 3fd303306fe29f51d0002ebdf6df9ed05194472a Mon Sep 17 00:00:00 2001 From: mountaincoding <86009219+mountaincoding@users.noreply.github.com> Date: Mon, 30 Nov 2026 14:34:35 -0700 Subject: [PATCH 2/2] ci: enforce Rust formatting checks --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a0025ed..148705d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -16,6 +16,8 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Check formatting + run: cargo fmt --all -- --check - name: Build run: cargo build --verbose - name: Run tests