From 11583e157c0e58c4332d8e6a00259fb08e8efe44 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 16 Mar 2023 10:17:56 -0500 Subject: [PATCH] refactor(help): Track via style via ANSI codes --- src/builder/arg.rs | 2 +- src/builder/styled_str.rs | 183 ++++++++++-------------------------- src/error/format.rs | 10 +- src/error/mod.rs | 2 +- src/output/fmt.rs | 8 +- src/output/help.rs | 12 +-- src/output/help_template.rs | 37 +++----- src/output/usage.rs | 10 +- 8 files changed, 82 insertions(+), 182 deletions(-) diff --git a/src/builder/arg.rs b/src/builder/arg.rs index bf898cbfd642..107676a9c5c1 100644 --- a/src/builder/arg.rs +++ b/src/builder/arg.rs @@ -4149,7 +4149,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/src/builder/styled_str.rs b/src/builder/styled_str.rs index dde3057b3845..fac37e661407 100644 --- a/src/builder/styled_str.rs +++ b/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