Stop ends animation and shows final mascot (only on success)
()
| 76 | |
| 77 | // Stop ends animation and shows final mascot (only on success) |
| 78 | func (ui *SimpleBuildUI) Stop() { |
| 79 | ui.mu.Lock() |
| 80 | if !ui.running { |
| 81 | ui.mu.Unlock() |
| 82 | return |
| 83 | } |
| 84 | ui.running = false |
| 85 | state := ui.state |
| 86 | ui.mu.Unlock() |
| 87 | |
| 88 | if ui.isTTY { |
| 89 | // Show cursor |
| 90 | fmt.Print("\033[?25h") |
| 91 | } |
| 92 | |
| 93 | // Print mascot on success or failure (but not during normal operation) |
| 94 | // Only print once per UI instance |
| 95 | ui.stopOnce.Do(func() { |
| 96 | if state == mascot.StateSuccess || state == mascot.StateFailed { |
| 97 | ui.printMascot() |
| 98 | } |
| 99 | }) |
| 100 | } |
| 101 | |
| 102 | // SetStatus updates mascot state and status |
| 103 | func (ui *SimpleBuildUI) SetStatus(state mascot.MascotState, status, detail string) { |
no test coverage detected