Terminal UI

This guide covers terminal UI helpers for commands, following Laravel-style CLI UX patterns for prompts, logs, and task feedback.

Displaying log messages

Use ctx.Logger() for severity levels: Debug, Info, Success, Warning, Error.

return command.New("deploy", "Deploy to production").
	RunE(func(ctx *command.Ctx) error {
		ctx.Logger().Debug("Loading deployment configuration")
		ctx.Logger().Info("Deploying application")
		ctx.Logger().Success("Deployment complete")
		ctx.Logger().Warning("SSL expires in 30 days")
		ctx.Logger().Error(err)
		return nil
	})

Formatting text with colors

Use ctx.Colors() for ANSI formatting: Red, Green, Yellow, Cyan, Bold, BgGreen, BgRed.

c := ctx.Colors()
ctx.Logger().Info(c.Green("[SUCCESS]") + " " + c.Red("[ERROR]"))
ctx.Logger().Info(c.BgGreen(" CREATED ") + " " + c.BgRed(" FAILED "))
ctx.Logger().Info(c.Bold("Important") + " " + c.Dim("details"))

Rendering tables

Render tables with ctx.UI().Table(). Apply colors to cells.

table := ctx.UI().Table()
table.Head("Migration", "Duration", "Status")
table.Row("20260108120000_create_users.go", "2ms", ctx.Colors().Green("DONE"))
table.Row("20260108120001_add_roles.go", "5ms", ctx.Colors().Red("FAILED"))
table.Render()

Creating boxed content with stickers

Boxed content with ctx.UI().Sticker(). Step-by-step instructions with ctx.UI().Instructions().

sticker := ctx.UI().Sticker()
sticker.Add("Started HTTP server").Add("")
sticker.Add("Local: " + ctx.Colors().Cyan("http://localhost:3333"))
sticker.Render()

// Instructions (arrow-prefixed)
steps := ctx.UI().Instructions()
steps.Add("Run npm install").Add("Copy .env.example to .env").Add("Run go run . migrate")
steps.Render()