Skip to content

feat: add --color support with failing test for multi-arg leaf coloring#344

Closed
KSXGitHub wants to merge 3 commits intoKSXGitHub:copilot/add-color-flag-and-mappingfrom
khai-slop-labs:claude/add-total-leaf-coloring-qUWmm
Closed

feat: add --color support with failing test for multi-arg leaf coloring#344
KSXGitHub wants to merge 3 commits intoKSXGitHub:copilot/add-color-flag-and-mappingfrom
khai-slop-labs:claude/add-total-leaf-coloring-qUWmm

Conversation

@KSXGitHub
Copy link
Owner

Implement the --color [auto|always|never] infrastructure from PR #339:

  • ColorWhen enum for CLI argument parsing
  • LsColors wrapper for LS_COLORS environment variable parsing
  • Coloring system with per-node color selection (Directory/Normal/Executable/Symlink)
  • Integration threading Coloring through the Visualizer

Add a failing test color_always_multiple_args that demonstrates the bug described in the review comment: when multiple path arguments are provided, build_coloring_map constructs paths like (total)/dir-a/file.txt for filesystem type checks, which don't exist on disk, causing symlinks and empty directories to be miscolored as normal files.

https://claude.ai/code/session_01KBTsrp6LL3TYRQ7CFF8jY6

claude added 3 commits March 6, 2026 19:10
Add a --color CLI flag that colorizes file and directory names in the
tree output based on the LS_COLORS environment variable, resolving KSXGitHub#11.

- `--color=auto` (default): colors when stdout is a TTY
- `--color=always`: always colors output
- `--color=never`: no colors

The color detection code is invoked only after pruning to save CPU/IO.
A HashMap maps childless node names to pre-rendered ANSI escape
sequences. Directory nodes (with children) use the directory color.

Key changes:
- New `ColorOption` clap value enum in `src/args/color_option.rs`
- New `Coloring` module in `src/coloring.rs` with LS_COLORS integration
- `Visualizer` gains an `Option<&Coloring>` field
- `TreeHorizontalSlice::display_colored()` renders names with ANSI
  codes while preserving correct column width alignment
- Regenerated help text, completions, and USAGE.md

https://claude.ai/code/session_01P8PBNPcM8sNBg8a1627iwZ
Implement the --color [auto|always|never] infrastructure from PR KSXGitHub#339:
- ColorWhen enum for CLI argument parsing
- LsColors wrapper for LS_COLORS environment variable parsing
- Coloring system with per-node color selection (Directory/Normal/Executable/Symlink)
- Integration threading Coloring through the Visualizer

Add a failing test `color_always_multiple_args` that demonstrates the bug
described in the review comment: when multiple path arguments are provided,
`build_coloring_map` constructs paths like `(total)/dir-a/file.txt` for
filesystem type checks, which don't exist on disk, causing symlinks and
empty directories to be miscolored as normal files.

https://claude.ai/code/session_01KBTsrp6LL3TYRQ7CFF8jY6
Adopt the incoming branch's --color architecture (ColorOption, crate::coloring::Coloring
with name-to-ANSI-prefix map, display_colored on TreeHorizontalSlice).

Remove superseded files from our branch (src/args/color.rs, src/ls_colors.rs,
src/visualizer/coloring.rs) and adapt the color_always_multiple_args test to
verify ANSI output directly rather than via a hand-built Coloring.

https://claude.ai/code/session_01KBTsrp6LL3TYRQ7CFF8jY6
@KSXGitHub KSXGitHub closed this Mar 8, 2026
@KSXGitHub KSXGitHub deleted the claude/add-total-leaf-coloring-qUWmm branch March 8, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants