cli/pkg/cmd/agent-task/shared/display.go
Kynan Ware 4fd6ae6e3a Refactor session state color logic to shared package
Moved the session state color selection logic from list.go to a new shared/display.go file as ColorFuncForSessionState. This improves code reuse and maintainability by centralizing the color mapping for session states.
2025-08-29 15:23:40 -06:00

25 lines
580 B
Go

package shared
import (
"github.com/cli/cli/v2/pkg/cmd/agent-task/capi"
"github.com/cli/cli/v2/pkg/iostreams"
)
// ColorFuncForSessionState returns a function that colors the session state
func ColorFuncForSessionState(s capi.Session, cs *iostreams.ColorScheme) func(string) string {
var stateColor func(string) string
switch s.State {
case "completed":
stateColor = cs.Green
case "canceled":
stateColor = cs.Muted
case "in_progress", "queued":
stateColor = cs.Yellow
case "failed":
stateColor = cs.Red
default:
stateColor = cs.Muted
}
return stateColor
}