2022-08-17 18:16:21 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
func Watch(ch <-chan *CompileReport, doneCh chan<- struct{}) {
|
|
|
|
defer close(doneCh)
|
|
|
|
|
|
|
|
states := map[*CompileConfig]CompileState{}
|
|
|
|
for _, cfg := range CompileConfigs {
|
|
|
|
states[cfg] = StateWaiting
|
|
|
|
}
|
|
|
|
|
|
|
|
cleared := false
|
|
|
|
|
|
|
|
for report := range ch {
|
|
|
|
states[report.Config] = report.State
|
|
|
|
if !*Silent {
|
|
|
|
PrintStates(states, cleared)
|
|
|
|
}
|
|
|
|
cleared = true
|
|
|
|
}
|
|
|
|
|
|
|
|
doneCh <- struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PrintStates(states map[*CompileConfig]CompileState, clear bool) {
|
|
|
|
if clear {
|
|
|
|
for i := 0; i < len(CompileConfigs); i++ {
|
|
|
|
goUp()
|
|
|
|
clearEOL()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, cfg := range CompileConfigs {
|
|
|
|
state, ok := states[cfg]
|
|
|
|
if !ok {
|
|
|
|
fmt.Println()
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2022-08-17 19:37:46 +02:00
|
|
|
fmt.Printf(fmt.Sprintf("%%-%ds %%s\n", MaxConfigStringLength), cfg.String(), state)
|
2022-08-17 18:16:21 +02:00
|
|
|
}
|
|
|
|
}
|