From 542ca9d1c941a7f58d7951e4322e08b423ad80f4 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 29 Nov 2023 11:50:03 -0500 Subject: [PATCH] cargo: Fix default features and make them all additive --- Cargo.toml | 4 ++-- src/style.rs | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 794331f..e79a6f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,12 +19,12 @@ authors = ["David Peter "] rust-version = "1.63.0" [features] -default = [] +default = ["nu-ansi-term"] +gnu_legacy = ["nu-ansi-term/gnu_legacy"] [dependencies] ansi_term = { version = "0.12", optional = true } nu-ansi-term = { version = "0.49", optional = true } -gnu_legacy = { package = "nu-ansi-term", version = "0.49", features = ["gnu_legacy"], optional = true } crossterm = { version = "0.26", optional = true } [dev-dependencies] diff --git a/src/style.rs b/src/style.rs index ebfc905..cd0e7c0 100644 --- a/src/style.rs +++ b/src/style.rs @@ -2,10 +2,6 @@ //! //! For more information, see //! [ANSI escape code (Wikipedia)](https://en.wikipedia.org/wiki/ANSI_escape_code). -#[cfg(all(feature = "nu-ansi-term", feature = "gnu_legacy"))] -compile_error!("`nu-ansi-term` and `gnu_legacy` may not be used at the same time"); -#[cfg(feature = "gnu_legacy")] -use gnu_legacy as nu_ansi_term; #[cfg(feature = "nu-ansi-term")] use nu_ansi_term; use std::collections::VecDeque; @@ -408,7 +404,7 @@ impl Style { /// /// ## Example for nu-ansi-term feature /// ``` - /// # #[cfg(feature = "nu-ansi-term")] + /// # #[cfg(all(feature = "nu-ansi-term", not(feature = "gnu_legacy")))] /// # { /// /// use lscolors::{Color, FontStyle, Style}; @@ -662,7 +658,7 @@ mod tests { ); } - #[cfg(feature = "nu-ansi-term")] + #[cfg(all(feature = "nu-ansi-term", not(feature = "gnu_legacy")))] #[test] fn coloring_nu_ansi_term() { let style = Style { @@ -677,7 +673,7 @@ mod tests { assert_eq!("\x1b[1;34mwow\x1b[0m", nu_ansi.paint("wow").to_string()); } - #[cfg(feature = "nu-ansi-term")] + #[cfg(all(feature = "nu-ansi-term", not(feature = "gnu_legacy")))] #[test] fn coloring_nu_ansi_term_with_reset() { let style = Style {