diff --git a/src/commands.rs b/src/commands.rs index bf0d9b7..1401b34 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -132,6 +132,12 @@ pub(crate) struct GlobalArgs { long_help = "Use a proxy for HTTP requests. This is useful if you are behind a firewall and need to use a proxy to access the internet." )] pub http_proxy: Option, + + #[clap( + long, + help = "Credentials to use for proxy authentication in the format username:password." + )] + pub proxy_credentials: Option, } #[derive(Debug, Clone, Parser)] diff --git a/src/main.rs b/src/main.rs index cbc624f..d7fe8ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -221,7 +221,11 @@ fn run(args: commands::Args) -> anyhow::Result<()> { let mut http_client = reqwest::blocking::Client::builder(); if let Some(proxy) = &globalargs.http_proxy { - let proxy = reqwest::Proxy::all(proxy)?; + let mut proxy = reqwest::Proxy::all(proxy)?; + if let Some(proxy_creds) = &globalargs.proxy_credentials { + let mut creds = proxy_creds.splitn(2, ':'); + proxy = proxy.basic_auth(creds.next().unwrap(), creds.next().unwrap()); + } http_client = http_client.proxy(proxy); } let http_client = http_client.build()?;