printChecksText prints the result in human-readable form to stderr.
(result *ChecksResult)
| 394 | |
| 395 | // printChecksText prints the result in human-readable form to stderr. |
| 396 | func printChecksText(result *ChecksResult) error { |
| 397 | switch result.State { |
| 398 | case CheckStateSuccess: |
| 399 | fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("PR #%s: all checks passed (%d total)", result.PRNumber, result.TotalCount))) |
| 400 | case CheckStateFailed: |
| 401 | fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("PR #%s: checks failed (%d total)", result.PRNumber, result.TotalCount))) |
| 402 | case CheckStatePending: |
| 403 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("PR #%s: checks pending (%d total)", result.PRNumber, result.TotalCount))) |
| 404 | case CheckStateNoChecks: |
| 405 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("PR #%s: no checks configured or triggered", result.PRNumber))) |
| 406 | case CheckStatePolicyBlocked: |
| 407 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("PR #%s: blocked by policy or account gate (%d total)", result.PRNumber, result.TotalCount))) |
| 408 | } |
| 409 | |
| 410 | // Always print the normalized state to stdout for machine consumption. |
| 411 | fmt.Fprintln(os.Stdout, string(result.State)) |
| 412 | return nil |
| 413 | } |