Skip to content

Commit d62da09

Browse files
REALERvolker1sharkdp
authored andcommitted
Add owo-colors feature to bin
1 parent f60f0c0 commit d62da09

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ gnu_legacy = ["nu-ansi-term/gnu_legacy"]
2626
ansi_term = { version = "0.12", optional = true }
2727
nu-ansi-term = { version = "0.50", optional = true }
2828
crossterm = { version = "0.27", optional = true }
29+
owo-colors = { version = "4.0", optional = true }
2930

3031
[dev-dependencies]
3132
tempfile = "^3"

src/bin.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ use lscolors::{LsColors, Style};
99
not(feature = "nu-ansi-term"),
1010
not(feature = "gnu_legacy"),
1111
not(feature = "ansi_term"),
12-
not(feature = "crossterm")
12+
not(feature = "crossterm"),
13+
not(feature = "owo-colors")
1314
))]
14-
compile_error!("one feature must be enabled: ansi_term, nu-ansi-term, crossterm, gnu_legacy");
15+
compile_error!(
16+
"one feature must be enabled: ansi_term, nu-ansi-term, crossterm, gnu_legacy, owo-colors"
17+
);
1518

1619
fn print_path(handle: &mut dyn Write, ls_colors: &LsColors, path: &str) -> io::Result<()> {
1720
for (component, style) in ls_colors.style_for_path_components(Path::new(path)) {
@@ -32,6 +35,12 @@ fn print_path(handle: &mut dyn Write, ls_colors: &LsColors, path: &str) -> io::R
3235
let ansi_style = style.map(Style::to_crossterm_style).unwrap_or_default();
3336
write!(handle, "{}", ansi_style.apply(component.to_string_lossy()))?;
3437
}
38+
#[cfg(feature = "owo-colors")]
39+
{
40+
use owo_colors::OwoColorize;
41+
let ansi_style = style.map(Style::to_owo_colors_style).unwrap_or_default();
42+
write!(handle, "{}", component.to_string_lossy().style(ansi_style))?;
43+
}
3544
}
3645
writeln!(handle)?;
3746

0 commit comments

Comments
 (0)