Skip to content

Respect NO_COLOR and non-TTY output #27

Closed

Description

@DataDave-Dev

Context

src/becwright/cli.py defines ANSI color constants unconditionally (RED = "\033[91m", etc.) and always emits them. When becwright check output is piped to a file or another tool, raw escape codes leak in, and the NO_COLOR convention is ignored. (The --json output is unaffected — this is about the human-readable output.)

Proposal

Disable colors when either:

  • the NO_COLOR environment variable is set, or
  • stdout is not a TTY (sys.stdout.isatty() is false).

Optionally add an explicit --no-color flag. Simplest implementation: set the color constants to empty strings in those cases.

Acceptance criteria

  • becwright check | cat and NO_COLOR=1 becwright check emit no escape sequences.
  • A test asserts this (e.g. capsys + monkeypatching isatty).

Files: src/becwright/cli.py (color constants near the top, _print_result).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions