mirror of
https://github.com/anthonyoteri/dredge.git
synced 2026-06-05 15:26:53 -04:00
Apply consistent formatting with cargo-fmt
This commit is contained in:
+1
-2
@@ -59,7 +59,6 @@ pub enum Commands {
|
|||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct RepoArgs {
|
pub struct RepoArgs {
|
||||||
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub command: RepoCommands,
|
pub command: RepoCommands,
|
||||||
}
|
}
|
||||||
@@ -67,4 +66,4 @@ pub struct RepoArgs {
|
|||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub enum RepoCommands {
|
pub enum RepoCommands {
|
||||||
List,
|
List,
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
pub mod repo;
|
pub mod repo;
|
||||||
|
|||||||
+12
-7
@@ -15,7 +15,6 @@ pub async fn handler(config: &Config, args: &RepoArgs) -> Result<(), ApiError> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct CatalogResponse {
|
struct CatalogResponse {
|
||||||
repositories: Vec<String>,
|
repositories: Vec<String>,
|
||||||
@@ -37,9 +36,13 @@ async fn handle_list(config: &Config, _args: &RepoArgs) -> Result<(), ApiError>
|
|||||||
|
|
||||||
if let Some(link_value) = headers.get(http::header::LINK) {
|
if let Some(link_value) = headers.get(http::header::LINK) {
|
||||||
let link_str = link_value.to_str()?;
|
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(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)?;
|
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 {
|
for repo in repo_list {
|
||||||
println!("{repo}");
|
println!("{repo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
+1
-3
@@ -50,7 +50,6 @@ impl From<xdg::BaseDirectoriesError> for ConfigError {
|
|||||||
/// An error related to the communication with the registry API.
|
/// An error related to the communication with the registry API.
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum ApiError {
|
pub enum ApiError {
|
||||||
|
|
||||||
/// Error parsing a URL
|
/// Error parsing a URL
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
UrlParseError(#[from] url::ParseError),
|
UrlParseError(#[from] url::ParseError),
|
||||||
@@ -64,8 +63,7 @@ pub enum ApiError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<reqwest::header::ToStrError> for ApiError {
|
impl From<reqwest::header::ToStrError> for ApiError {
|
||||||
|
|
||||||
fn from(other: reqwest::header::ToStrError) -> Self {
|
fn from(other: reqwest::header::ToStrError) -> Self {
|
||||||
Self::ResponseHeaderParseError(Box::from(other))
|
Self::ResponseHeaderParseError(Box::from(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
use crate::cli::Cli;
|
use crate::cli::Cli;
|
||||||
|
use crate::cli::Commands;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::error::ConfigError;
|
use crate::error::ConfigError;
|
||||||
use crate::error::DredgeError;
|
use crate::error::DredgeError;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use crate::cli::Commands;
|
|
||||||
|
|
||||||
pub(crate) mod cli;
|
pub(crate) mod cli;
|
||||||
mod commands;
|
mod commands;
|
||||||
@@ -90,4 +90,4 @@ async fn main() -> Result<(), DredgeError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user