From bdbfe6470f60c7163f4337ffccc2d9382da5dfc8 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 16 Mar 2023 10:17:56 -0500 Subject: [PATCH] refactor(help): Track style via ANSI codes --- clap_builder/src/builder/arg.rs | 2 +- clap_builder/src/builder/styled_str.rs | 187 +++++++---------------- clap_builder/src/error/format.rs | 10 +- clap_builder/src/error/mod.rs | 2 +- clap_builder/src/output/fmt.rs | 8 +- clap_builder/src/output/help.rs | 12 +- clap_builder/src/output/help_template.rs | 37 ++--- clap_builder/src/output/usage.rs | 10 +- 8 files changed, 84 insertions(+), 184 deletions(-) diff --git a/clap_builder/src/builder/arg.rs b/clap_builder/src/builder/arg.rs index 577d9682..574e6fba 100644 --- a/clap_builder/src/builder/arg.rs +++ b/clap_builder/src/builder/arg.rs @@ -4280,7 +4280,7 @@ impl Arg { styled.literal("-"); styled.literal(s); } - styled.extend(self.stylize_arg_suffix(required).into_iter()); + styled.push_styled(&self.stylize_arg_suffix(required)); styled } diff --git a/clap_builder/src/builder/styled_str.rs b/clap_builder/src/builder/styled_str.rs index dde3057b..fac37e66 100644 --- a/clap_builder/src/builder/styled_str.rs +++ b/clap_builder/src/builder/styled_str.rs @@ -2,27 +2,13 @@ /// /// For now, this is the same as a [`Str`][crate::builder::Str]. This exists to reserve space in /// the API for exposing terminal styling. -#[derive(Clone, Default, Debug, PartialEq, Eq)] -pub struct StyledStr { - #[cfg(feature = "color")] - pieces: Vec<(Option