Skip to content

Commit

Permalink
Enable native-certs in ureq by default
Browse files Browse the repository at this point in the history
* Add features to the version string
  • Loading branch information
acuteenvy committed May 9, 2024
1 parent 1ad3c57 commit 3092e01
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 4 deletions.
78 changes: 78 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ name = "tldr"
path = "src/main.rs"

[features]
default = ["socks-proxy"]
# The default TLS implementation is Rustls with native certificates.
# Disabling the `native-certs` feature switches to Rustls with webpki-roots.
default = ["socks-proxy", "native-certs"]
socks-proxy = ["ureq/socks-proxy"]
native-certs = ["ureq/native-certs"]

[dependencies]
clap = { version = "4.5.4", features = ["derive"] }
Expand Down
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ use std::process;
/// The version of the tldr client specification being implemented.
const CLIENT_SPEC: &str = "2.2";

const TLS: &str = if cfg!(feature = "native-certs") {
"Rustls + native certs"
} else {
"Rustls + webpki-roots"
};

const SOCKS: &str = if cfg!(feature = "socks-proxy") {
"+SOCKS"
} else {
"-SOCKS"
};

fn is_debug_build() -> bool {
env::var("PROFILE").unwrap() == "debug"
}
Expand Down Expand Up @@ -48,4 +60,5 @@ fn main() {

// Put the version string inside an environment variable during the build.
println!("cargo:rustc-env=VERSION_STRING={ver}");
println!("cargo:rustc-env=FEATURES=[{TLS}, {SOCKS}]");
}
6 changes: 3 additions & 3 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ const AFTER_HELP: &str = if cfg!(target_os = "windows") {
#[command(
arg_required_else_help = true,
about,
// VERSION_STRING is generated and set in the build script.
version = env!("VERSION_STRING"),
// These env vars are generated and set in the build script.
version = concat!(env!("VERSION_STRING"), '\n', env!("FEATURES")),
disable_version_flag = true,
after_help = AFTER_HELP,
help_template = "{before-help}{name} {version}\n\
help_template = "{before-help}{name} {version}\n\n\
{about-with-newline}\n\
{usage-heading} {usage}\n\n\
{all-args}{after-help}"
Expand Down

0 comments on commit 3092e01

Please sign in to comment.