Skip to content

feat: Display colored error/warning messages in TTY terminals #317

@Kimchikilla

Description

@Kimchikilla

Problem

Currently all error output from gws is raw JSON, which is hard to read in an interactive terminal session:

{"error":{"code":404,"message":"Not Found","reason":"notFound"}}

Proposal

Detect whether stdout/stderr is a TTY and display human-friendly colored messages when running interactively:

✗ notFound (404): Not Found          ← red bold
⚠️  Model Armor: injection detected    ← yellow bold
💡 API not enabled for your project    ← yellow bold

When piped or redirected, keep the existing JSON output for backward compatibility.

Implementation notes

  • Use std::io::IsTerminal (stable since Rust 1.70) for TTY detection
  • colored crate (or alternatively anstream/anstyle which are already indirect deps via clap) for ANSI colors
  • Error output goes to stderr; JSON pipe output stays on stdout
  • Zero behavior change for scripted/piped usage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions