From 6d5aaae5a9279f5ea39d4b3cc8bbb035583f5692 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 19 Apr 2023 10:57:00 -0500 Subject: [PATCH 1/2] feat(help): Allow access to current Styles --- clap_builder/src/builder/command.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clap_builder/src/builder/command.rs b/clap_builder/src/builder/command.rs index abd743382e6..357ddeb8394 100644 --- a/clap_builder/src/builder/command.rs +++ b/clap_builder/src/builder/command.rs @@ -3364,7 +3364,9 @@ impl Command { } } - pub(crate) fn get_styles(&self) -> &Styles { + /// Return the current `Styles` for the `Command` + #[inline] + pub fn get_styles(&self) -> &Styles { self.app_ext.get().unwrap_or_default() } From 1ca073f212a5ba836e5dff9502cc65292b1016c8 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 19 Apr 2023 11:00:00 -0500 Subject: [PATCH 2/2] docs(help): Fill in styles docs --- clap_builder/src/builder/command.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/clap_builder/src/builder/command.rs b/clap_builder/src/builder/command.rs index 357ddeb8394..799623581b2 100644 --- a/clap_builder/src/builder/command.rs +++ b/clap_builder/src/builder/command.rs @@ -1081,22 +1081,21 @@ impl Command { } } - /// Sets when to color output. + /// Sets the [`Styles`] for terminal output /// /// **NOTE:** This choice is propagated to all child subcommands. /// - /// **NOTE:** Default behaviour is [`ColorChoice::Auto`]. + /// **NOTE:** Default behaviour is [`Styles::default`]. /// /// # Examples /// /// ```no_run /// # use clap_builder as clap; - /// # use clap::{Command, ColorChoice}; + /// # use clap::{Command, ColorChoice, builder::Styles}; /// Command::new("myprog") - /// .color(ColorChoice::Never) + /// .styles(Styles::styled().usage(Default::default())) /// .get_matches(); /// ``` - /// [`ColorChoice::Auto`]: crate::ColorChoice::Auto #[cfg(feature = "color")] #[inline] #[must_use]