Skip to content

Show colors in the output of bref command - #57

Merged
mnapoli merged 2 commits into
mainfrom
command-ansi-colors
Sep 28, 2026
Merged

mnapoli merged 2 commits into
mainfrom
command-ansi-colors

Conversation

@mnapoli

@mnapoli mnapoli commented Sep 27, 2026

Copy link
Copy Markdown
Member

When its output is a terminal, bref command now asks Bref Cloud for colors (ansi: true when starting the command). Bref Cloud then adds --ansi to Laravel (artisan) and Symfony (bin/console) commands: on Lambda their output is never a terminal, so without it they never write colors. The output is printed as before, and the terminal renders the colors.

  • The decision (which consoles accept --ansi, a command that already sets --ansi/--no-ansi is left alone) is made by Bref Cloud: the CLI only says whether it can show colors, from $output->isDecorated() (so NO_COLOR, pipes and redirections disable it).
  • Piped or redirected output stays without colors.
  • A Bref Cloud version that doesn't know the field ignores it: this can be released independently.

Tested against Bref Cloud with the server side of this change: under a TTY, bref command about prints Laravel's colors (^[[32;1mEnvironment^[[39;22m ...) and a failing command's error block renders in white on red; piped, the output has no escape codes; the current release shows no colors, as before.

Command now accepts a BrefCloudClient in its constructor, like the other commands, for the new CommandTest.

When the output is a terminal, `bref command` asks Bref Cloud for colors: Bref Cloud adds
`--ansi` to Laravel and Symfony commands, which otherwise never write colors on Lambda (their
output is not a terminal there). The output is printed as it was, the terminal renders the
colors. When the output is piped or redirected, nothing changes.

Claude-Session: https://claude.ai/code/session_01Awk33iZ9mDSg1xgSAPkgGK
Creating `Bref\Cli\Application` turns warnings into exceptions, and with the lowest
dependencies (Symfony Console 5 on PHP 8.2) loading Symfony's `HelperSet` triggers a
deprecation notice that then became a fatal error. The test now sets up `IO` like the
application does, and runs the command directly.

Claude-Session: https://claude.ai/code/session_01Awk33iZ9mDSg1xgSAPkgGK
@mnapoli
mnapoli added this pull request to stack #60 September 27, 2026 20:18
@mnapoli
mnapoli merged commit 4976196 into main Sep 28, 2026
4 checks passed
@mnapoli
mnapoli deleted the command-ansi-colors branch September 28, 2026 12:29
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