summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2020-07-06 12:42:11 +0800
committerSebastian Thiel <sebastian.thiel@icloud.com>2020-07-06 12:42:11 +0800
commit86f16c3042d9f8ba400512c8f2916c3a40e2d1f8 (patch)
treefaee9d7c1afb7cb4c595d3cd0dda95a62fbc37a0
parent3e0d4b022ff8d6ce5115894f3b6ad68f01ff370f (diff)
for a moment I thought 'colored' could be used, but…
…it's really allocation heavy. Something simpler might be it, what about termcolor?
-rw-r--r--Cargo.lock12
-rw-r--r--Cargo.toml1
-rw-r--r--src/aggregate.rs8
3 files changed, 20 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 74d5f8b..68c0401 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -87,6 +87,17 @@ dependencies = [
]
[[package]]
+name = "colored"
+version = "1.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
+dependencies = [
+ "atty",
+ "lazy_static",
+ "winapi 0.3.9",
+]
+
+[[package]]
name = "crossbeam"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -219,6 +230,7 @@ dependencies = [
"anyhow",
"atty",
"byte-unit",
+ "colored",
"crosstermion",
"filesize",
"flume",
diff --git a/Cargo.toml b/Cargo.toml
index 06e1a70..43bc451 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,6 +27,7 @@ filesize = "0.2.0"
flume = {version = "0.7.1", default-features = false}
anyhow = "1.0.31"
crosstermion = { version = "0.1.3", default-features = false, features = ["tui-react-crossterm", "input-thread-flume"]}
+colored = "1.9.3"
[[bin]]
name="dua"
diff --git a/src/aggregate.rs b/src/aggregate.rs
index d40a0cf..57103ac 100644
--- a/src/aggregate.rs
+++ b/src/aggregate.rs
@@ -1,5 +1,6 @@
use crate::{crossdev, InodeFilter, WalkOptions, WalkResult};
use anyhow::Result;
+use colored::Colorize;
use filesize::PathExt;
use std::borrow::Cow;
use std::{fmt, io, path::Path};
@@ -129,7 +130,12 @@ fn write_path<C: fmt::Display>(
writeln!(
out,
"{byte_color}{:>byte_column_width$}{byte_color_reset} {path_color}{}{path_color_reset}{}",
- options.byte_format.display(num_bytes).to_string(), // needed for formatting to work (unless we implement it ourselves)
+ options
+ .byte_format
+ .display(num_bytes)
+ .to_string()
+ .as_str()
+ .green(), // needed for formatting to work (unless we implement it ourselves)
path.as_ref().display(),
if num_errors == 0 {
Cow::Borrowed("")