feat(summary): Quit out of program when user interrupts loading indicator (fix #21)
This commit is contained in:
parent
d434ff273b
commit
2528fbe9eb
10
summary.go
10
summary.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
@ -41,10 +42,14 @@ func (m summaryviewer) View() string {
|
||||
}
|
||||
|
||||
func summary() {
|
||||
finished := false
|
||||
p := tea.NewProgram(initialIndicator(("Fetching time logs...")))
|
||||
go func() {
|
||||
if _, err := p.Run(); err != nil {
|
||||
panic("An error occured.")
|
||||
fmt.Println(err)
|
||||
}
|
||||
if !finished {
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -61,9 +66,10 @@ func summary() {
|
||||
viewer.total_time += time.Duration(t.Time * int64(time.Second))
|
||||
}
|
||||
|
||||
finished = true
|
||||
p.Send(IndicatorInfo{info: "Done", quitting: true})
|
||||
p.RestoreTerminal()
|
||||
p.Quit()
|
||||
p.Wait()
|
||||
|
||||
program := tea.NewProgram(viewer)
|
||||
if _, err := program.Run(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user