Skip to content

feat(output): implement --color (status coloring, aws-style)#22

Merged
vks-team merged 1 commit into
mainfrom
feat/color-output
Jul 1, 2026
Merged

feat(output): implement --color (status coloring, aws-style)#22
vks-team merged 1 commit into
mainfrom
feat/color-output

Conversation

@vks-team

@vks-team vks-team commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

--color was a no-op: registered, validated (v1.3.1), and tab-completed, but the value was never read and nothing in the CLI ever emitted color. This wires it end-to-end, mirroring the AWS CLI's --color semantics.

Behavior

formatter.ColorEnabled(mode, w) resolves the flag exactly like aws:

  • on → always color
  • off → never
  • auto (default) → only when stdout is a terminal and NO_COLOR is unset

When enabled, text and table output color recognized status values:

  • green: ACTIVE, READY, RUNNING, AVAILABLE, HEALTHY, SUCCEEDED, COMPLETED
  • yellow: CREATING, DELETING, UPDATING, UPGRADING, PENDING, PROVISIONING, RECONCILING
  • red: ERROR, FAILED, UNHEALTHY, DEGRADED

json output is never colored (must stay valid JSON — also matches aws). Applied to both the VKS and vServer output paths.

Notes

  • No new dependencies: TTY detection uses os.ModeCharDevice.
  • Alignment safe: column widths are computed on the raw text; ANSI codes are wrapped around the already-padded cell, so they're zero-width and tables stay aligned.
  • Non-status values are never colored.

Testing

  • New tests: ColorEnabled (on/off/auto + NO_COLOR), status coloring in table, no-color default, non-status left uncolored, alignment preserved.
  • go vet ./... clean; full go test ./... passes; build clean.

🤖 Generated with Claude Code

The --color flag was accepted, validated, and completed but did nothing. Wire
it end-to-end: formatter.ColorEnabled resolves on/off/auto exactly like the AWS
CLI (auto = stdout is a terminal and NO_COLOR is unset), and text/table output
now colors recognized status values (ACTIVE/READY green, ERROR/FAILED red,
CREATING/PENDING/UPDATING yellow). JSON output is never colored so it stays
valid. Column widths are computed on the raw text, so ANSI codes don't break
table alignment. Applied to both the VKS and vServer output paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vks-team vks-team merged commit 78d4f4f into main Jul 1, 2026
4 checks passed
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.

1 participant