From bd0e3ccda720b8523b711d466e75b0e66730a982 Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Wed, 7 Dec 2022 21:19:01 -0500 Subject: [PATCH] impl Default for HttpConfig, so field isn't required in config file these changes allow omitting the http field of the top-level config, relying on the defaults instead. previously, not having an [http] section in the config.toml would fail to parse. --- src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.rs b/src/main.rs index c911c30..9f58f2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -194,6 +194,7 @@ pub struct Config { pub output: OutputConfig, /// Download settings #[clap(flatten)] + #[serde(default)] pub http: HttpConfig, /// Specify configuration values using the provided TOML file, instead of /// via command line flags. The values in the config file will override @@ -274,6 +275,16 @@ impl std::fmt::Debug for TargetRegistryConfig { } } +impl Default for HttpConfig { + fn default() -> Self { + Self { + user_agent: default_user_agent(), + requests_per_second: default_requests_per_second(), + max_concurrent_requests: default_max_concurrent_requests(), + } + } +} + impl std::fmt::Debug for HttpConfig { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.debug_struct("Config")