ChronoTomato/internal/frontend/terminal.go
Sebastian Mark 0f8fde3143 fix: update GoTomato model field names
adjust field names due to breaking changes in GoTomato v0.0.4
2024-10-28 07:56:37 +01:00

52 lines
1 KiB
Go

package frontend
import (
"fmt"
"github.com/fatih/color"
"strings"
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
)
func terminalOutput(pomodoro GoTomato.ServerMessage) {
var (
modePrefix string
timerOutput string
)
fmt.Print("\033[H\033[2J") // Clears the screen
// header
color.Blue("Work: %d ◊ Break: %d ◊ Longbreak: %d\n\n",
pomodoro.Settings.Work/60,
pomodoro.Settings.ShortBreak/60,
pomodoro.Settings.LongBreak/60,
)
//body
switch pomodoro.Mode {
case "Idle":
modePrefix = " "
timerOutput = ""
default:
modePrefix = " "
if pomodoro.Paused {
modePrefix = " "
}
minutes := pomodoro.TimeLeft / 60
seconds := pomodoro.TimeLeft % 60
timerOutput = fmt.Sprintf("⏳ %02d:%02d", minutes, seconds)
}
fmt.Printf("Session: %d/%d\n",
pomodoro.Session,
pomodoro.Settings.Sessions,
)
fmt.Printf("%s %s\n", modePrefix, pomodoro.Mode)
fmt.Printf(timerOutput)
//footer
fmt.Printf(strings.Repeat("\n", 3))
color.White("space: start/pause/resume • s: stop • r: reset pomodoro • q: quit")
}