Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(help): Stabilize styling support #5094

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _FEATURES = minimal default wasm full debug release
_FEATURES_minimal = --no-default-features --features "std"
_FEATURES_default =
_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_debug = ${_FEATURES_full} --features debug --features clap_complete/debug
_FEATURES_release = ${_FEATURES_full} --release
Expand Down
2 changes: 1 addition & 1 deletion clap_builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tag-name = "v{{version}}"
[features]
default = ["std", "color", "help", "usage", "error-context", "suggestions"]
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
std = ["anstyle/std"] # support for no_std in a backwards-compatible way
Expand Down
1 change: 0 additions & 1 deletion clap_builder/src/builder/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,6 @@ impl Command {
#[cfg(feature = "color")]
#[inline]
#[must_use]
#[cfg(feature = "unstable-styles")]
pub fn styles(mut self, styles: Styles) -> Self {
self.app_ext.set(styles);
self
Expand Down
6 changes: 0 additions & 6 deletions clap_builder/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ mod debug_asserts;
#[cfg(test)]
mod tests;

#[cfg(feature = "unstable-styles")]
pub mod styling;
#[cfg(not(feature = "unstable-styles"))]
pub(crate) mod styling;

pub use self::str::Str;
pub use action::ArgAction;
Expand All @@ -40,7 +37,6 @@ pub use range::ValueRange;
pub use resettable::IntoResettable;
pub use resettable::Resettable;
pub use styled_str::StyledStr;
#[cfg(feature = "unstable-styles")]
pub use styling::Styles;
pub use value_hint::ValueHint;
pub use value_parser::_AutoValueParser;
Expand Down Expand Up @@ -69,5 +65,3 @@ pub(crate) use self::str::Inner as StrInner;
pub(crate) use action::CountType;
pub(crate) use arg_settings::{ArgFlags, ArgSettings};
pub(crate) use command::AppTag;
#[cfg(not(feature = "unstable-styles"))]
pub(crate) use styling::Styles;
2 changes: 0 additions & 2 deletions clap_builder/src/builder/styling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ pub use anstyle::*;
///
/// clap v3 styling
/// ```rust
/// # #[cfg(feature = "unstable-styles")] {
/// # use clap_builder as clap;
/// # use clap::builder::styling::*;
/// let styles = Styles::styled()
/// .header(AnsiColor::Yellow.on_default())
/// .usage(AnsiColor::Green.on_default())
/// .literal(AnsiColor::Green.on_default())
/// .placeholder(AnsiColor::Green.on_default());
/// # }
/// ```
#[derive(Clone, Debug)]
#[allow(missing_copy_implementations)] // Large enough type that I want an explicit `clone()` for now
Expand Down
1 change: 0 additions & 1 deletion src/_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@
//! **Warning:** These may contain breaking changes between minor releases.
//!
//! * **unstable-v5**: Preview features which will be stable on the v5.0 release
//! * **unstable-styles**: Custom theming support for clap
2 changes: 1 addition & 1 deletion src/bin/stdio-fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
.action(clap::ArgAction::SetTrue)
.long_help("more log"),
);
#[cfg(feature = "unstable-styles")]
#[cfg(feature = "color")]
{
use clap::builder::styling;
let styles = styling::Styles::styled()
Expand Down
2 changes: 0 additions & 2 deletions tests/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ fn example_tests() {
// In-work
//#[cfg(feature = "unstable-v5")] // Currently has failures
//"unstable-v5",
#[cfg(feature = "unstable-styles")]
"unstable-styles",
]
.join(" ");
t.register_bins(trycmd::cargo::compile_examples(["--features", &features]).unwrap());
Expand Down
2 changes: 0 additions & 2 deletions tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ fn ui_tests() {
// In-work
//#[cfg(feature = "unstable-v5")] // Currently has failures
//"unstable-v5",
#[cfg(feature = "unstable-styles")]
"unstable-styles",
]
.join(" ");
t.register_bins(trycmd::cargo::compile_examples(["--features", &features]).unwrap());
Expand Down