Skip to content

Commit

Permalink
dependencies: switch from colored to owo-colors
Browse files Browse the repository at this point in the history
owo-colors is well-maintained, zero-allocation, zero-dependencies crate
for terminal colors. Also it works on any type that implements Display trait,
not just on strings.
  • Loading branch information
murlakatamenka committed Sep 1, 2022
1 parent b5ec900 commit 6a636d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
25 changes: 7 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ itertools = "0.10.0"
num_cpus = "1.10.0"
filesize = "0.2.0"
anyhow = "1.0.31"
colored = "2.0.0"
trash = { version = "2.1.5", optional = true, default-features = false, features = ["coinit_apartmentthreaded"] }

# 'tui' related
Expand All @@ -37,6 +36,7 @@ tui = { version = "0.17.0", optional = true, default-features = false }
tui-react = { version = "0.17.0", optional = true }
open = { version = "3.0", optional = true }
wild = "2.0.4"
owo-colors = "3.5.0"

[target.'cfg(all(target_os = "macos", target_arch = "aarch64"))'.dependencies]
sysinfo = { version = "0.23.2", default-features = false }
Expand Down
16 changes: 6 additions & 10 deletions src/aggregate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{crossdev, InodeFilter, WalkOptions, WalkResult};
use anyhow::Result;
use colored::{Color, Colorize};
use filesize::PathExt;
use owo_colors::{AnsiColors as Color, OwoColorize};
use std::{borrow::Cow, io, path::Path};
use std::{
sync::{
Expand Down Expand Up @@ -199,23 +199,19 @@ fn output_colored_path(
path: impl AsRef<Path>,
num_bytes: u128,
num_errors: u64,
path_color: Option<colored::Color>,
path_color: Option<Color>,
) -> std::result::Result<(), io::Error> {
writeln!(
out,
"{:>byte_column_width$} {}{}",
options
.byte_format
.display(num_bytes)
.to_string()
.as_str()
.green(),
options.byte_format.display(num_bytes).green(),
{
let path = path.as_ref().display().to_string();
let path = path.as_ref().display();
match path_color {
Some(color) => path.color(color),
None => path.normal(),
None => path.color(Color::Default),
}
.to_string()
},
if num_errors == 0 {
Cow::Borrowed("")
Expand Down

0 comments on commit 6a636d5

Please sign in to comment.