From 26a7750e86ec0a10139c3f394033377468f7d7ec Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Fri, 14 Feb 2025 17:08:17 -0800 Subject: [PATCH] feat: add color to help text Uses the same coloring that cargo uses to make it easier to skim read the help --- Cargo.lock | 11 +++++++++++ crates/bin/Cargo.toml | 3 ++- crates/bin/src/args.rs | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 8d65f0a0..ecfe2d8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -578,6 +578,7 @@ dependencies = [ "binstalk", "binstalk-manifests", "clap", + "clap-cargo", "compact_str", "dirs", "embed-resource", @@ -715,6 +716,16 @@ dependencies = [ "clap_derive", ] +[[package]] +name = "clap-cargo" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d546f0e84ff2bfa4da1ce9b54be42285767ba39c688572ca32412a09a73851e5" +dependencies = [ + "anstyle", + "clap", +] + [[package]] name = "clap_builder" version = "4.5.29" diff --git a/crates/bin/Cargo.toml b/crates/bin/Cargo.toml index 256bea3d..dac3c073 100644 --- a/crates/bin/Cargo.toml +++ b/crates/bin/Cargo.toml @@ -26,6 +26,7 @@ atomic-file-install = { version = "1.0.9", path = "../atomic-file-install" } binstalk = { path = "../binstalk", version = "0.28.24", default-features = false } binstalk-manifests = { path = "../binstalk-manifests", version = "0.15.21" } clap = { version = "4.5.3", features = ["derive", "env"] } +clap-cargo = "0.15.2" compact_str = "0.8.0" dirs = "6.0.0" file-format = { version = "0.26.0", default-features = false } @@ -40,8 +41,8 @@ strum_macros = "0.27.0" supports-color = "3.0.0" tempfile = "3.5.0" tokio = { version = "1.35.0", features = ["rt-multi-thread", "signal"], default-features = false } -tracing-core = "0.1.32" tracing = { version = "0.1.39", default-features = false } +tracing-core = "0.1.32" tracing-log = { version = "0.2.0", default-features = false } tracing-subscriber = { version = "0.3.17", features = ["fmt", "json", "ansi"], default-features = false } zeroize = "1.8.1" diff --git a/crates/bin/src/args.rs b/crates/bin/src/args.rs index 8cf81ac7..0b681823 100644 --- a/crates/bin/src/args.rs +++ b/crates/bin/src/args.rs @@ -35,6 +35,7 @@ use zeroize::Zeroizing; arg_required_else_help(true), // Avoid conflict with version_req disable_version_flag(true), + styles = clap_cargo::style::CLAP_STYLING, )] pub struct Args { /// Packages to install.