stackabletech / stackabletech/stackablectl

feat: Implement colored output (with `NO_COLOR` support)

Open
#145 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
10
Forks
5
Avg merge
4h 41m
Merged PRs (30d)
4

Description

Colours sould only be enabled when the terminal supports them.
For example, when redirecting output or piping to cat, there should be no escape sequences.

I believe there needs to be a condition around the pretty method (or maybe it should be handled by tracing_subscriber::fmt):

https://github.com/stackabletech/stackable-cockpit/blob/fe37d494359d91e32ae309a9f6d382b4a486c5a0/rust/stackablectl/src/main.rs#L31

Examples:

stackablectl --log-level=DEBUG stack list > /tmp/stackablectl.stdout       # plain redirect
stackablectl --log-level=DEBUG stack list | cat > /tmp/stackablectl.stdout # pipe through cat
TERM= stackablectl --log-level=DEBUG stack list > /tmp/stackablectl.stdout # explicitly set TERM to nothing

If I open it in VIM, it looks like this:

image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in rust/stackablectl/src/main.rs around the linked pretty method, and compare whether tracing_subscriber::fmt should handle terminal detection. Run the listed stackablectl commands with redirected and piped output, including an empty TERM, and confirm that non-interactive output has no escape sequences while supported terminal output remains colored and NO_COLOR is respected.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.