Skip to content

feat(diagnose): add --no-color flag for CI/scripting - #58

Open
MsfPablo wants to merge 1 commit into
francomano:masterfrom
MsfPablo:feat/42-no-color
Open

feat(diagnose): add --no-color flag for CI/scripting#58
MsfPablo wants to merge 1 commit into
francomano:masterfrom
MsfPablo:feat/42-no-color

Conversation

@MsfPablo

@MsfPablo MsfPablo commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Closes #42

Summary

formatText and formatComparisonText prefix the report with a 📊 header and each result with an emoji status glyph (✅/❌/⚠️). That breaks CI logs, log files, and pipes that expect plain text — the emoji render as escapes or mojibake in many log viewers and terminals without UTF-8.

Add a --no-color flag (default false) that, when set, swaps the status emoji for plain bracketed markers and drops the header glyph, so the text report is safe to grep, store, and pipe.

$ proxyctl diagnose --url https://example.com --no-color
Diagnosis Results
────────────────────────────────────────────────

1. [PASS] public_ip
   Status: passed | Severity: info | Confidence: 90%
   Public IP resolved via proxy.

2. [FAIL] dns_leak
   Status: failed | Severity: critical | Confidence: 80%
   DNS bypassed the proxy.

Changes

  • cmd/cli/commands/diagnose.go
    • --no-color bool flag registered on diagnoseCmd (default false).
    • statusMarker(result) helper: returns [PASS]/[FAIL]/[ERROR] when --no-color is set, otherwise the existing emoji.
    • textHeader(label) helper: returns the bare label when --no-color is set, otherwise 📊 <label>.
    • formatText and formatComparisonText use the helpers.
  • cmd/cli/commands/diagnose_test.go
    • TestFormatTextOmitsEmojiWhenNoColor: with noColor=true, asserts no 📊/✅/❌/⚠️ remain, [PASS]/[FAIL] and the header label appear, and that formatMarkdown is unaffected (still uses emoji).

Acceptance criteria (#42)

  • --no-color flag exists and defaults to false
  • When set, text output contains no emoji
  • JSON/HTML/Markdown output is unaffected
  • A test verifies the flag behavior

Verification

go build ./...
go test ./cmd/cli/commands/
gofmt -l cmd/cli/commands/
go vet ./cmd/cli/commands/

formatText and formatComparisonText prefix the report with a 📊 header and
each result with an emoji status glyph, which breaks CI logs, log files, and
pipes that expect plain text. Add a --no-color flag (default false) that
swaps the emoji for bracketed markers ([PASS]/[FAIL]/[ERROR]) and drops the
header glyph, so the text report is safe to grep and store. JSON, HTML, and
Markdown output are unchanged.

Closes francomano#42

@francomano francomano left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Richiesta di modifica: --no-color promette di disabilitare le emoji per CI/log/pipeline, ma viene applicato soltanto al report formattato. Rimangono emoji nel banner, nelle righe "Running diagnosis"/"Via proxy", nei messaggi di errore e nel messaggio di salvataggio. Centralizza i marker/heading o rendi condizionali anche questi percorsi, quindi aggiungi un test end-to-end del comando che verifichi l’assenza di emoji nell’intero stdout.

@francomano francomano left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English version of my change request: --no-color promises to disable emoji for CI, logs, and pipelines, but it currently only affects the formatted report. Emoji remain in the banner, the "Running diagnosis" / "Via proxy" lines, error messages, and the save confirmation. Please centralize these markers/headings or make those paths conditional as well, then add an end-to-end command test confirming that the complete stdout contains no emoji.

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.

Add --no-color flag for CI/scripting

2 participants