refactor(times): Handle 'since' option before starting bubble tea indicator

This commit is contained in:
Noah 2024-04-07 13:54:46 -05:00
parent c5b82d5dbe
commit df48225954

View File

@ -15,6 +15,12 @@ import (
) )
func times() { func times() {
since, err := tparse.AddDuration(time.Now(), "-"+*arguments.Times.since)
if err != nil {
fmt.Printf("Failed to parse time string '%s'\n", *arguments.Times.since)
os.Exit(1)
}
finished := false finished := false
p := tea.NewProgram(initialIndicator("Fetching time logs...")) p := tea.NewProgram(initialIndicator("Fetching time logs..."))
go func() { go func() {
@ -27,12 +33,6 @@ func times() {
} }
}() }()
since, err := tparse.AddDuration(time.Now(), "-"+*arguments.Times.since)
if err != nil {
fmt.Printf("Failed to parse time string '%s'\n", *arguments.Times.since)
os.Exit(1)
}
times := getTimeLogs(since, func(repo gitea.Repository, took time.Duration) { times := getTimeLogs(since, func(repo gitea.Repository, took time.Duration) {
p.Send(IndicatorInfo{ p.Send(IndicatorInfo{
info: fmt.Sprintf("%s / %s", repo.Owner.UserName, repo.Name), info: fmt.Sprintf("%s / %s", repo.Owner.UserName, repo.Name),