Apply consistent formatting with cargo-fmt

This commit is contained in:
Anthony Oteri
2023-09-13 21:45:37 -04:00
parent 74b2f87e51
commit 957b0bb2cc
5 changed files with 17 additions and 15 deletions
-1
View File
@@ -59,7 +59,6 @@ pub enum Commands {
#[derive(Debug, Args)]
pub struct RepoArgs {
#[command(subcommand)]
pub command: RepoCommands,
}
+9 -4
View File
@@ -15,7 +15,6 @@ pub async fn handler(config: &Config, args: &RepoArgs) -> Result<(), ApiError> {
Ok(())
}
#[derive(Deserialize)]
struct CatalogResponse {
repositories: Vec<String>,
@@ -39,7 +38,11 @@ async fn handle_list(config: &Config, _args: &RepoArgs) -> Result<(), ApiError>
let link_str = link_value.to_str()?;
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(())
}
-2
View File
@@ -50,7 +50,6 @@ impl From<xdg::BaseDirectoriesError> 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,7 +63,6 @@ pub enum ApiError {
}
impl From<reqwest::header::ToStrError> for ApiError {
fn from(other: reqwest::header::ToStrError) -> Self {
Self::ResponseHeaderParseError(Box::from(other))
}
+1 -1
View File
@@ -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;