From 957b0bb2cccf51d21042da9ceec24f0506f28922 Mon Sep 17 00:00:00 2001 From: Anthony Oteri Date: Wed, 13 Sep 2023 21:45:37 -0400 Subject: [PATCH] Apply consistent formatting with cargo-fmt --- src/cli.rs | 3 +-- src/commands.rs | 2 +- src/commands/repo.rs | 19 ++++++++++++------- src/error.rs | 4 +--- src/main.rs | 4 ++-- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 6971a18..bef1dd5 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -59,7 +59,6 @@ pub enum Commands { #[derive(Debug, Args)] pub struct RepoArgs { - #[command(subcommand)] pub command: RepoCommands, } @@ -67,4 +66,4 @@ pub struct RepoArgs { #[derive(Debug, Subcommand)] pub enum RepoCommands { List, -} \ No newline at end of file +} diff --git a/src/commands.rs b/src/commands.rs index 35eb3df..c426b23 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1 +1 @@ -pub mod repo; \ No newline at end of file +pub mod repo; diff --git a/src/commands/repo.rs b/src/commands/repo.rs index 71b328c..e078a05 100644 --- a/src/commands/repo.rs +++ b/src/commands/repo.rs @@ -15,7 +15,6 @@ pub async fn handler(config: &Config, args: &RepoArgs) -> Result<(), ApiError> { Ok(()) } - #[derive(Deserialize)] struct CatalogResponse { repositories: Vec, @@ -37,9 +36,13 @@ async fn handle_list(config: &Config, _args: &RepoArgs) -> Result<(), ApiError> if let Some(link_value) = headers.get(http::header::LINK) { let link_str = link_value.to_str()?; - let parts:Vec<&str> = link_str.split(';').collect(); + let parts: Vec<&str> = link_str.split(';').collect(); if let Some(url_part) = parts.first() { - if let Some(uri) = url_part.trim().strip_prefix('<').and_then(|s| s.strip_suffix('>')) { + if let Some(uri) = url_part + .trim() + .strip_prefix('<') + .and_then(|s| s.strip_suffix('>')) + { url = config.registry_url.join(uri)?; } } @@ -48,12 +51,14 @@ async fn handle_list(config: &Config, _args: &RepoArgs) -> Result<(), ApiError> } } - let repo_list: Vec<&str> = responses.iter().flat_map(|r| r.repositories.iter().map(String::as_str)).collect(); - + let repo_list: Vec<&str> = responses + .iter() + .flat_map(|r| r.repositories.iter().map(String::as_str)) + .collect(); + for repo in repo_list { println!("{repo}"); } Ok(()) - -} \ No newline at end of file +} diff --git a/src/error.rs b/src/error.rs index 469e0a0..14c450f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -50,7 +50,6 @@ impl From for ConfigError { /// An error related to the communication with the registry API. #[derive(Error, Debug)] pub enum ApiError { - /// Error parsing a URL #[error(transparent)] UrlParseError(#[from] url::ParseError), @@ -64,8 +63,7 @@ pub enum ApiError { } impl From for ApiError { - fn from(other: reqwest::header::ToStrError) -> Self { Self::ResponseHeaderParseError(Box::from(other)) } -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index 4be96b0..cded77f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ use crate::cli::Cli; +use crate::cli::Commands; use crate::config::Config; use crate::error::ConfigError; use crate::error::DredgeError; use clap::Parser; use std::ffi::OsString; use std::path::PathBuf; -use crate::cli::Commands; pub(crate) mod cli; mod commands; @@ -90,4 +90,4 @@ async fn main() -> Result<(), DredgeError> { } Ok(()) -} \ No newline at end of file +}