use clap::Parser;
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "eggfetch", version, about, long_about = None)]
#[allow(clippy::struct_excessive_bools)]
pub(crate) struct Cli {
pub(crate) url: String,
#[arg(short = 'X', long = "method")]
pub(crate) method: Option<String>,
#[arg(short = 'H', long = "header", action = clap::ArgAction::Append)]
pub(crate) header: Vec<String>,
#[arg(short = 'q', long = "query", action = clap::ArgAction::Append)]
pub(crate) query: Vec<String>,
#[arg(long = "form", action = clap::ArgAction::Append)]
pub(crate) form: Vec<String>,
#[arg(long = "file", action = clap::ArgAction::Append)]
pub(crate) file: Vec<String>,
#[arg(long = "body")]
pub(crate) body: Option<String>,
#[arg(long = "body-file")]
pub(crate) body_file: Option<String>,
#[arg(long = "json")]
pub(crate) json: Option<String>,
#[arg(short = 'o', long = "output")]
pub(crate) output: Option<PathBuf>,
#[arg(long = "download")]
pub(crate) download: bool,
#[arg(long = "no-clobber")]
pub(crate) no_clobber: bool,
#[arg(short = 'i', long = "include")]
pub(crate) include: bool,
#[arg(long = "headers-only")]
pub(crate) headers_only: bool,
#[arg(long = "no-body")]
pub(crate) no_body: bool,
#[arg(long = "json-output")]
pub(crate) json_output: bool,
#[arg(long = "ndjson", conflicts_with = "json_output")]
pub(crate) ndjson: bool,
#[arg(long = "base64")]
pub(crate) base64: bool,
#[arg(long = "timeout")]
pub(crate) timeout: Option<u64>,
#[arg(long = "connect-timeout")]
pub(crate) connect_timeout: Option<u64>,
#[arg(long = "total-timeout")]
pub(crate) total_timeout: Option<u64>,
#[arg(long = "read-timeout")]
pub(crate) read_timeout: Option<u64>,
#[arg(long = "follow", default_value_t = true)]
pub(crate) follow: bool,
#[arg(long = "no-follow", overrides_with = "follow")]
pub(crate) no_follow: bool,
#[arg(long = "max-redirects", default_value = "20")]
pub(crate) max_redirects: usize,
#[arg(long = "no-downgrade")]
pub(crate) no_downgrade: bool,
#[arg(long = "auth", env = "EGGFETCH_AUTH", conflicts_with = "bearer")]
pub(crate) auth: Option<String>,
#[arg(long = "bearer", env = "EGGFETCH_BEARER", conflicts_with = "auth")]
pub(crate) bearer: Option<String>,
#[arg(long = "cookie", action = clap::ArgAction::Append)]
pub(crate) cookie: Vec<String>,
#[arg(long = "cookie-jar")]
pub(crate) cookie_jar: Option<PathBuf>,
#[arg(long = "proxy", env = "EGGFETCH_PROXY")]
pub(crate) proxy: Option<String>,
#[arg(long = "proxy-auth", env = "EGGFETCH_PROXY_AUTH")]
pub(crate) proxy_auth: Option<String>,
#[arg(long = "no-proxy")]
pub(crate) no_proxy: Option<String>,
#[arg(long = "no-verify")]
pub(crate) no_verify: bool,
#[arg(long = "cacert")]
pub(crate) cacert: Option<PathBuf>,
#[arg(long = "cert")]
pub(crate) cert: Option<PathBuf>,
#[arg(long = "key")]
pub(crate) key: Option<PathBuf>,
#[arg(long = "retry")]
pub(crate) retry: Option<usize>,
#[arg(long = "retry-delay")]
pub(crate) retry_delay: Option<u64>,
#[arg(long = "http1")]
pub(crate) http1: bool,
#[arg(long = "http2")]
pub(crate) http2: bool,
#[arg(long = "http3")]
pub(crate) http3: bool,
#[arg(long = "no-compress")]
pub(crate) no_compress: bool,
#[arg(long = "max-body-size")]
pub(crate) max_body_size: Option<usize>,
#[arg(long = "max-decompression-ratio")]
pub(crate) max_decompression_ratio: Option<f64>,
#[arg(long = "check-status")]
pub(crate) check_status: bool,
#[arg(short = 'v', long = "verbose")]
pub(crate) verbose: bool,
#[arg(long = "generate-completion", value_enum)]
pub(crate) generate_completion: Option<Shell>,
}
impl std::fmt::Debug for Cli {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Cli")
.field("url", &crate::output::safe_url_for_display(&self.url))
.field("method", &self.method)
.field("header", &"<redacted-if-auth>")
.field("auth", &self.auth.as_ref().map(|_| "<redacted>"))
.field("bearer", &self.bearer.as_ref().map(|_| "<redacted>"))
.field(
"proxy",
&self
.proxy
.as_ref()
.map(|p| crate::output::safe_url_for_display(p)),
)
.field(
"proxy_auth",
&self.proxy_auth.as_ref().map(|_| "<redacted>"),
)
.finish_non_exhaustive()
}
}
#[derive(clap::ValueEnum, Clone, Debug)]
#[allow(clippy::enum_variant_names)] pub(crate) enum Shell {
Bash,
Zsh,
Fish,
PowerShell,
Elvish,
}