Skip to content

Commit 7ab5a3f

Browse files
authored
Fix using autodetect for colors on color=always|never CLI options (#253)
1 parent 57567cf commit 7ab5a3f

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ All user visible changes to `cucumber` crate will be documented in this file. Th
66

77

88

9+
## [0.19.1] · 2022-12-??
10+
[0.19.1]: /../../tree/v0.19.1
11+
12+
[Diff](/../../compare/v0.19.0...v0.19.1) | [Milestone](/../../milestone/23)
13+
14+
### Fixed
15+
16+
- Using autodetect for colors on `color=always|never` CLI options. ([#253])
17+
18+
[#253]: /../../pull/253
19+
20+
21+
22+
923
## [0.19.0] · 2022-12-16
1024
[0.19.0]: /../../tree/v0.19.0
1125

src/writer/out.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! Tools for writing output.
1212
13-
use std::{borrow::Cow, io, str};
13+
use std::{borrow::Cow, io, mem, str};
1414

1515
use console::Style;
1616
use derive_more::{Deref, DerefMut, Display, From, Into};
@@ -68,11 +68,20 @@ impl Styles {
6868

6969
/// Applies the given [`Coloring`] to these [`Styles`].
7070
pub fn apply_coloring(&mut self, color: Coloring) {
71-
match color {
72-
Coloring::Auto => {}
73-
Coloring::Always => self.is_present = true,
74-
Coloring::Never => self.is_present = false,
75-
}
71+
let is_present = match color {
72+
Coloring::Always => true,
73+
Coloring::Never => false,
74+
Coloring::Auto => return,
75+
};
76+
77+
let this = mem::take(self);
78+
self.ok = this.ok.force_styling(is_present);
79+
self.skipped = this.skipped.force_styling(is_present);
80+
self.err = this.err.force_styling(is_present);
81+
self.retry = this.retry.force_styling(is_present);
82+
self.header = this.header.force_styling(is_present);
83+
self.bold = this.bold.force_styling(is_present);
84+
self.is_present = is_present;
7685
}
7786

7887
/// Returns [`Styles`] with brighter colors.

0 commit comments

Comments
 (0)