-
-
Notifications
You must be signed in to change notification settings - Fork 17
feat: --color
#339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: --color
#339
Changes from 19 commits
57f5055
0bf8a92
eb866f3
80e99c3
33316ce
f622673
c0d0062
3c22b24
9e47e4d
ab5cc0a
bc6faff
92cede4
1b2eb7f
c78baaa
2c0b44f
d78e31e
1d3a5d3
860d755
2f6425a
bc2f468
9e97f67
d4416d4
2580418
34ed31e
fdbd102
ba3e69f
eb4848f
415de11
ac318a9
81a548a
868c886
2543757
b27a943
2311f29
8120a77
d09ff5d
398e43e
2ad9147
cf3e12b
ade71b1
20d508b
aea511c
e7dee6b
d0200ef
7d8d39b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,16 +5,22 @@ use crate::{ | |||||||||||||||||||||||||||||
| get_size::GetSize, | ||||||||||||||||||||||||||||||
| hardlink::{DeduplicateSharedSize, HardlinkIgnorant, RecordHardlinks}, | ||||||||||||||||||||||||||||||
| json_data::{BinaryVersion, JsonData, JsonDataBody, JsonShared, JsonTree, SchemaVersion}, | ||||||||||||||||||||||||||||||
| ls_colors::LsColors, | ||||||||||||||||||||||||||||||
| os_string_display::OsStringDisplay, | ||||||||||||||||||||||||||||||
| reporter::ParallelReporter, | ||||||||||||||||||||||||||||||
| runtime_error::RuntimeError, | ||||||||||||||||||||||||||||||
| size, | ||||||||||||||||||||||||||||||
| status_board::GLOBAL_STATUS_BOARD, | ||||||||||||||||||||||||||||||
| visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, | ||||||||||||||||||||||||||||||
| visualizer::{BarAlignment, Color, Coloring, ColumnWidthDistribution, Direction, Visualizer}, | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
| use pipe_trait::Pipe; | ||||||||||||||||||||||||||||||
| use serde::Serialize; | ||||||||||||||||||||||||||||||
| use std::{io::stdout, iter::once, path::PathBuf}; | ||||||||||||||||||||||||||||||
| use std::{ | ||||||||||||||||||||||||||||||
| collections::HashMap, | ||||||||||||||||||||||||||||||
| io::stdout, | ||||||||||||||||||||||||||||||
| iter::once, | ||||||||||||||||||||||||||||||
| path::{Path, PathBuf}, | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /// The sub program of the main application. | ||||||||||||||||||||||||||||||
| pub struct Sub<Size, SizeGetter, HardlinksHandler, Report> | ||||||||||||||||||||||||||||||
|
|
@@ -49,6 +55,8 @@ where | |||||||||||||||||||||||||||||
| pub min_ratio: Fraction, | ||||||||||||||||||||||||||||||
| /// Preserve order of entries. | ||||||||||||||||||||||||||||||
| pub no_sort: bool, | ||||||||||||||||||||||||||||||
| /// Whether to color the output. | ||||||||||||||||||||||||||||||
| pub color: Option<LsColors>, | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| impl<Size, SizeGetter, HardlinksHandler, Report> Sub<Size, SizeGetter, HardlinksHandler, Report> | ||||||||||||||||||||||||||||||
|
|
@@ -74,6 +82,7 @@ where | |||||||||||||||||||||||||||||
| reporter, | ||||||||||||||||||||||||||||||
| min_ratio, | ||||||||||||||||||||||||||||||
| no_sort, | ||||||||||||||||||||||||||||||
| color, | ||||||||||||||||||||||||||||||
| } = self; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| let max_depth = max_depth.get(); | ||||||||||||||||||||||||||||||
|
|
@@ -98,6 +107,7 @@ where | |||||||||||||||||||||||||||||
| files: vec![".".into()], | ||||||||||||||||||||||||||||||
| hardlinks_handler, | ||||||||||||||||||||||||||||||
| reporter, | ||||||||||||||||||||||||||||||
| color, | ||||||||||||||||||||||||||||||
| ..self | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| .run(); | ||||||||||||||||||||||||||||||
|
|
@@ -187,12 +197,19 @@ where | |||||||||||||||||||||||||||||
| .or(deduplication_result); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| let coloring: Option<Coloring> = color.map(|ls_colors| { | ||||||||||||||||||||||||||||||
| let mut map = HashMap::new(); | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| let mut map = HashMap::new(); | |
| let mut map = HashMap::new(); | |
| // NOTE: When `pdu` is invoked with multiple path arguments, a synthetic | |
| // root node (renamed to "(total)") is created. Calling `build_coloring_map` | |
| // on that synthetic root can lead to non-existent filesystem paths like | |
| // "(total)/path1/file.txt" being passed to `file_color`, which in turn | |
| // causes all filesystem-type checks (is_dir, is_symlink, etc.) to fail and | |
| // results in incorrect coloring. The intended behavior is to build the | |
| // coloring map per real subtree (each original argument) so that only | |
| // actual filesystem paths are used for type detection. | |
| // | |
| // For now, we keep the single-root behavior here; special handling for | |
| // synthetic aggregate roots should be implemented inside `build_coloring_map` | |
| // (by skipping synthetic roots and traversing their children individually). |
Uh oh!
There was an error while loading. Please reload this page.