use crate::fetcher::{Fetcher, FetcherOptions};
#[derive(Debug, clap::Parser)]
#[command(next_help_heading = "Client")]
pub struct ClientArguments {
#[arg(short, long, default_value = "5s")]
pub timeout: humantime::Duration,
#[arg(short, long, default_value = "5")]
pub retries: usize,
#[arg(long, default_value = "10s")]
pub default_retry_after: humantime::Duration,
}
impl From<ClientArguments> for FetcherOptions {
fn from(value: ClientArguments) -> Self {
FetcherOptions::new()
.timeout(value.timeout)
.retries(value.retries)
.retry_after(value.default_retry_after.into())
}
}
impl ClientArguments {
pub async fn new_fetcher(self) -> Result<Fetcher, anyhow::Error> {
Fetcher::new(self.into()).await
}
}