Skip to content

feat: add test:console-color command to verify color tag rendering (framework#1571) - #158

Closed
goravel-agent wants to merge 1 commit into
masterfrom
implement/2026-10-15-pr1571-color-tags
Closed

goravel-agent wants to merge 1 commit into
masterfrom
implement/2026-10-15-pr1571-color-tags

Conversation

@goravel-agent

@goravel-agent goravel-agent commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Bumps github.com/goravel/framework to v1.18.1-0.20261013093243-4da928651f19, the head of framework PR #1571, restoring <red> / <fg=green> color-tag rendering that pterm v0.12.84 had dropped.
  • Adds go run . artisan test:console-color, one manual run that shows the prefix printers, the style/fg/bg/nested tag forms with their exact rendered bytes, color.StripColor over tagged, raw-ANSI, and mixed input, and TwoColumnDetail tagged-vs-pre-colored layout matching.
  • Leaves the process color state as it found it: the command snapshots and restores color.Enable() / color.Disable(), prints the disable/enable toggle section, and reports the disabled-entry notice instead of failing when --no-ansi already latched color off.

Why

Goravel renders console color tags such as <fg=green>ok</> through gookit/color. Framework PR #1571 ("restore color tag rendering for pterm v0.12.84 via gookit/color") re-added gookit/color v1.6.1 as a direct dependency after pterm v0.12.84 stopped bundling it, so tags are parsed again instead of leaking as literal text. This branch bumps the example app to that PR head and adds a runnable command that demonstrates the restored behavior from the example app itself, so a future dependency update cannot silently regress it. The bump also pulls in the PR head's transitive dependency drift: gookit/color v1.6.1, pterm v0.12.84, go-runewidth v0.0.31, and the newer otel/x/grpc versions that commit requires.

func (r *ConsoleColorCommand) Handle(ctx console.Context) error {
	ctx.Line("<fg=yellow;op=bold>Color tag rendering check (framework#1571)</>")
	ctx.NewLine()

	// 1. Prefix printers render tags through gookit as well.
	ctx.Line("<fg=cyan>1. Prefix printers</>")
	ctx.Info("<fg=green>Application is healthy</>")
	ctx.Warning("<fg=yellow>Queue worker is not running</>")
	ctx.Success("<green>Migration finished</>")
	ctx.Error("<fg=red>Cache connection failed</>")
	ctx.Comment("<fg=gray>Checking cache store</>")
	ctx.NewLine()

	// 2. Tag forms, each rendered visually and then as exact bytes.
	ctx.Line("<fg=cyan>2. Tag forms (visual, then exact rendered bytes)</>")
	ctx.Line(fmt.Sprintf("   style tag bytes: %q", color.Sprint(redTestTag)))
	ctx.Line("   fg attribute (green): <fg=green>ok</>")
	ctx.Line(fmt.Sprintf("   fg attribute bytes: %q", color.Sprint("<fg=green>ok</>")))
	ctx.Line(fmt.Sprintf("   nested bytes: %q", color.Red().Sprint("outer <fg=green>inner</> end")))
	ctx.NewLine()

	return nil
}

Before the bump, tags printed literally, so colored output had to be pre-rendered by hand, and support/console measured column widths on the raw tag text, which skewed alignment. After the bump, tags resolve to ANSI and widths are measured on the rendered text, so the tagged and pre-colored forms produce identical layout. Running go run . artisan test:console-color in a fresh process prints all of those cases, including a layout match: true line and the StripColor results for tagged, raw-ANSI, and mixed input; a regression now shows up as literal <fg=green> text in the output. When color was already latched off (for example by --no-ansi), the command says so and returns without failing, and if tags are still cleared after forcing color.Enable() it reports that rendering is broken with a non-zero exit.

@goravel-agent
goravel-agent requested a review from a team as a code owner October 15, 2026 10:11
…ramework#1571)

Bumps github.com/goravel/framework to v1.18.1-0.20261013093243-4da928651f19 (head of framework#1571), which restores <red>/<fg=green> tag rendering after pterm v0.12.84 dropped gookit/color.

The test:console-color command prints every case in one run: prefix printers, tag forms with exact rendered bytes, color.StripColor on tagged/raw-ANSI/mixed input, TwoColumnDetail tagged-vs-pre-colored layout, and the color.Disable()/Enable() toggle.
@hwbrzzl
hwbrzzl force-pushed the implement/2026-10-15-pr1571-color-tags branch from 4e53ae3 to e07ca33 Compare October 17, 2026 02:02
@goravel-agent goravel-agent changed the title test: add color tag rendering coverage (framework#1571) feat: add test:console-color command to verify color tag rendering (framework#1571) Oct 17, 2026
@hwbrzzl hwbrzzl closed this Oct 17, 2026
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.

2 participants