diff --git a/lychee-bin/src/options.rs b/lychee-bin/src/options.rs index 067f5e737d..f4fc71204b 100644 --- a/lychee-bin/src/options.rs +++ b/lychee-bin/src/options.rs @@ -148,7 +148,7 @@ impl LycheeOptions { } #[allow(clippy::struct_excessive_bools)] -#[derive(Parser, Debug, Deserialize, Clone)] +#[derive(Parser, Debug, Deserialize, Clone, Default)] pub(crate) struct Config { /// Verbose program output #[clap(flatten)] @@ -452,6 +452,7 @@ impl Config { require_https: false; cookie_jar: None; include_fragments: false; + accept: AcceptSelector::default(); } if self @@ -469,3 +470,25 @@ impl Config { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_accept_status_codes() { + let toml = Config { + accept: AcceptSelector::from_str("200..=204, 429, 500").unwrap(), + ..Default::default() + }; + + let mut cli = Config::default(); + cli.merge(toml); + + assert!(cli.accept.contains(429)); + assert!(cli.accept.contains(200)); + assert!(cli.accept.contains(203)); + assert!(cli.accept.contains(204)); + assert!(!cli.accept.contains(205)); + } +}