diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-06 12:57:47 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-06 12:57:47 +0800 |
commit | e867e58ebd2febc66342f0337f08b75574b24e02 (patch) | |
tree | 4278455424ecfacdba40fd91ab83f9e5a5a18e36 | |
parent | 86f16c3042d9f8ba400512c8f2916c3a40e2d1f8 (diff) |
termcolor spends 1200 lines on handlings buffers, and it's not liking plain io::Write
Which means it doesn't like what's currently there. So let's go back to
what can actually work: colored.
-rw-r--r-- | Cargo.lock | 31 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/aggregate.rs | 9 |
3 files changed, 22 insertions, 20 deletions
@@ -87,17 +87,6 @@ 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" @@ -230,7 +219,6 @@ dependencies = [ "anyhow", "atty", "byte-unit", - "colored", "crosstermion", "filesize", "flume", @@ -242,6 +230,7 @@ dependencies = [ "petgraph", "pretty_assertions", "structopt", + "termcolor", "termion", "tui", "tui-react 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -708,6 +697,15 @@ dependencies = [ ] [[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + +[[package]] name = "termion" version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -825,6 +823,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -27,7 +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" +termcolor = "1.1.0" [[bin]] name="dua" diff --git a/src/aggregate.rs b/src/aggregate.rs index 57103ac..a216089 100644 --- a/src/aggregate.rs +++ b/src/aggregate.rs @@ -1,9 +1,9 @@ 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}; +use termcolor; use termion::color; /// Aggregate the given `paths` and write information about them to `out` in a human-readable format. @@ -130,12 +130,7 @@ 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() - .as_str() - .green(), // needed for formatting to work (unless we implement it ourselves) + options.byte_format.display(num_bytes), path.as_ref().display(), if num_errors == 0 { Cow::Borrowed("") |