feat(help): Stabilize styling support

Fixes #3234
This commit is contained in:
Ed Page 2023-08-28 09:49:48 -05:00
parent f66484153a
commit eb53db89f8
9 changed files with 3 additions and 17 deletions

View file

@ -16,7 +16,7 @@ _FEATURES = minimal default wasm full debug release
_FEATURES_minimal = --no-default-features --features "std" _FEATURES_minimal = --no-default-features --features "std"
_FEATURES_default = _FEATURES_default =
_FEATURES_wasm = --no-default-features --features "std help usage error-context suggestions" --features "deprecated derive cargo env unicode string" _FEATURES_wasm = --no-default-features --features "std help usage error-context suggestions" --features "deprecated derive cargo env unicode string"
_FEATURES_full = --features "deprecated derive cargo env unicode string wrap_help unstable-styles" _FEATURES_full = --features "deprecated derive cargo env unicode string wrap_help"
_FEATURES_next = ${_FEATURES_full} --features unstable-v5 _FEATURES_next = ${_FEATURES_full} --features unstable-v5
_FEATURES_debug = ${_FEATURES_full} --features debug --features clap_complete/debug _FEATURES_debug = ${_FEATURES_full} --features debug --features clap_complete/debug
_FEATURES_release = ${_FEATURES_full} --release _FEATURES_release = ${_FEATURES_full} --release

View file

@ -32,7 +32,7 @@ tag-name = "v{{version}}"
[features] [features]
default = ["std", "color", "help", "usage", "error-context", "suggestions"] default = ["std", "color", "help", "usage", "error-context", "suggestions"]
debug = ["dep:backtrace"] # Enables debug messages debug = ["dep:backtrace"] # Enables debug messages
unstable-doc = ["cargo", "wrap_help", "env", "unicode", "string", "unstable-styles"] # for docs.rs unstable-doc = ["cargo", "wrap_help", "env", "unicode", "string"] # for docs.rs
# Used in default # Used in default
std = ["anstyle/std"] # support for no_std in a backwards-compatible way std = ["anstyle/std"] # support for no_std in a backwards-compatible way

View file

@ -1170,7 +1170,6 @@ impl Command {
#[cfg(feature = "color")] #[cfg(feature = "color")]
#[inline] #[inline]
#[must_use] #[must_use]
#[cfg(feature = "unstable-styles")]
pub fn styles(mut self, styles: Styles) -> Self { pub fn styles(mut self, styles: Styles) -> Self {
self.app_ext.set(styles); self.app_ext.set(styles);
self self

View file

@ -23,10 +23,7 @@ mod debug_asserts;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
#[cfg(feature = "unstable-styles")]
pub mod styling; pub mod styling;
#[cfg(not(feature = "unstable-styles"))]
pub(crate) mod styling;
pub use self::str::Str; pub use self::str::Str;
pub use action::ArgAction; pub use action::ArgAction;
@ -40,7 +37,6 @@ pub use range::ValueRange;
pub use resettable::IntoResettable; pub use resettable::IntoResettable;
pub use resettable::Resettable; pub use resettable::Resettable;
pub use styled_str::StyledStr; pub use styled_str::StyledStr;
#[cfg(feature = "unstable-styles")]
pub use styling::Styles; pub use styling::Styles;
pub use value_hint::ValueHint; pub use value_hint::ValueHint;
pub use value_parser::_AutoValueParser; pub use value_parser::_AutoValueParser;
@ -69,5 +65,3 @@ pub(crate) use self::str::Inner as StrInner;
pub(crate) use action::CountType; pub(crate) use action::CountType;
pub(crate) use arg_settings::{ArgFlags, ArgSettings}; pub(crate) use arg_settings::{ArgFlags, ArgSettings};
pub(crate) use command::AppTag; pub(crate) use command::AppTag;
#[cfg(not(feature = "unstable-styles"))]
pub(crate) use styling::Styles;

View file

@ -10,7 +10,6 @@ pub use anstyle::*;
/// ///
/// clap v3 styling /// clap v3 styling
/// ```rust /// ```rust
/// # #[cfg(feature = "unstable-styles")] {
/// # use clap_builder as clap; /// # use clap_builder as clap;
/// # use clap::builder::styling::*; /// # use clap::builder::styling::*;
/// let styles = Styles::styled() /// let styles = Styles::styled()
@ -18,7 +17,6 @@ pub use anstyle::*;
/// .usage(AnsiColor::Green.on_default()) /// .usage(AnsiColor::Green.on_default())
/// .literal(AnsiColor::Green.on_default()) /// .literal(AnsiColor::Green.on_default())
/// .placeholder(AnsiColor::Green.on_default()); /// .placeholder(AnsiColor::Green.on_default());
/// # }
/// ``` /// ```
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[allow(missing_copy_implementations)] // Large enough type that I want an explicit `clone()` for now #[allow(missing_copy_implementations)] // Large enough type that I want an explicit `clone()` for now

View file

@ -26,4 +26,3 @@
//! **Warning:** These may contain breaking changes between minor releases. //! **Warning:** These may contain breaking changes between minor releases.
//! //!
//! * **unstable-v5**: Preview features which will be stable on the v5.0 release //! * **unstable-v5**: Preview features which will be stable on the v5.0 release
//! * **unstable-styles**: Custom theming support for clap

View file

@ -12,7 +12,7 @@ fn main() {
.action(clap::ArgAction::SetTrue) .action(clap::ArgAction::SetTrue)
.long_help("more log"), .long_help("more log"),
); );
#[cfg(feature = "unstable-styles")] #[cfg(feature = "color")]
{ {
use clap::builder::styling; use clap::builder::styling;
let styles = styling::Styles::styled() let styles = styling::Styles::styled()

View file

@ -36,8 +36,6 @@ fn example_tests() {
// In-work // In-work
//#[cfg(feature = "unstable-v5")] // Currently has failures //#[cfg(feature = "unstable-v5")] // Currently has failures
//"unstable-v5", //"unstable-v5",
#[cfg(feature = "unstable-styles")]
"unstable-styles",
] ]
.join(" "); .join(" ");
t.register_bins(trycmd::cargo::compile_examples(["--features", &features]).unwrap()); t.register_bins(trycmd::cargo::compile_examples(["--features", &features]).unwrap());

View file

@ -36,8 +36,6 @@ fn ui_tests() {
// In-work // In-work
//#[cfg(feature = "unstable-v5")] // Currently has failures //#[cfg(feature = "unstable-v5")] // Currently has failures
//"unstable-v5", //"unstable-v5",
#[cfg(feature = "unstable-styles")]
"unstable-styles",
] ]
.join(" "); .join(" ");
t.register_bins(trycmd::cargo::compile_examples(["--features", &features]).unwrap()); t.register_bins(trycmd::cargo::compile_examples(["--features", &features]).unwrap());