ColorFuncForSessionState returns a function that colors the session state
(s capi.Session, cs *iostreams.ColorScheme)
| 7 | |
| 8 | // ColorFuncForSessionState returns a function that colors the session state |
| 9 | func ColorFuncForSessionState(s capi.Session, cs *iostreams.ColorScheme) func(string) string { |
| 10 | var stateColor func(string) string |
| 11 | switch s.State { |
| 12 | case "completed": |
| 13 | stateColor = cs.Green |
| 14 | case "cancelled": |
| 15 | stateColor = cs.Muted |
| 16 | case "in_progress", "queued": |
| 17 | stateColor = cs.Yellow |
| 18 | case "failed": |
| 19 | stateColor = cs.Red |
| 20 | default: |
| 21 | stateColor = cs.Muted |
| 22 | } |
| 23 | |
| 24 | return stateColor |
| 25 | } |
| 26 | |
| 27 | // SessionStateString returns the humane/capitalised form of the given session state. |
| 28 | func SessionStateString(state string) string { |
nothing calls this directly
no outgoing calls
no test coverage detected