Skip to content

Commit

Permalink
Fix using autodetect for colors on color=always|never CLI options (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ilslv committed Dec 29, 2022
1 parent 57567cf commit 7ab5a3f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
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

0 comments on commit 7ab5a3f

Please sign in to comment.