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

Fix color=always|never CLI options #253

Merged
merged 2 commits into from
Dec 29, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ All user visible changes to `cucumber` crate will be documented in this file. Th



## [0.19.1] · 2022-12-??
[0.19.1]: /../../tree/v0.19.1

[Diff](/../../compare/v0.19.0...v0.19.1) | [Milestone](/../../milestone/23)

### Fixed

- Using autodetect for colors on `color=always|never` CLI options. ([#253])

[#253]: /../../pull/253




## [0.19.0] · 2022-12-16
[0.19.0]: /../../tree/v0.19.0

Expand Down
21 changes: 15 additions & 6 deletions src/writer/out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//! Tools for writing output.

use std::{borrow::Cow, io, str};
use std::{borrow::Cow, io, mem, str};

use console::Style;
use derive_more::{Deref, DerefMut, Display, From, Into};
Expand Down Expand Up @@ -68,11 +68,20 @@ impl Styles {

/// Applies the given [`Coloring`] to these [`Styles`].
pub fn apply_coloring(&mut self, color: Coloring) {
match color {
Coloring::Auto => {}
Coloring::Always => self.is_present = true,
Coloring::Never => self.is_present = false,
}
let is_present = match color {
Coloring::Always => true,
Coloring::Never => false,
Coloring::Auto => return,
};

let this = mem::take(self);
self.ok = this.ok.force_styling(is_present);
self.skipped = this.skipped.force_styling(is_present);
self.err = this.err.force_styling(is_present);
self.retry = this.retry.force_styling(is_present);
self.header = this.header.force_styling(is_present);
self.bold = this.bold.force_styling(is_present);
self.is_present = is_present;
}

/// Returns [`Styles`] with brighter colors.
Expand Down