ChronoTomato/cmd/client/helper/terminal.go

52 lines
1 KiB
Go
Raw Normal View History

package helper
2024-10-22 11:13:41 +00:00
import (
"fmt"
"github.com/alecthomas/colour"
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
2024-10-22 11:13:41 +00:00
)
// Return terminal output based on the passed ServerMessage
func TerminalOutput(pomodoro GoTomato.ServerMessage) string {
var (
output string
modePrefix string
timerOutput string
)
2024-10-22 11:13:41 +00:00
// header
output += colour.Sprintf("^D^4Work: %d ◊ Break: %d ◊ Longbreak: %d^R\n\n",
pomodoro.Settings.Work/60,
pomodoro.Settings.ShortBreak/60,
pomodoro.Settings.LongBreak/60,
2024-10-22 11:13:41 +00:00
)
//body
switch pomodoro.Mode {
2024-10-22 11:13:41 +00:00
case "Idle":
modePrefix = " "
2024-10-22 11:13:41 +00:00
timerOutput = ""
default:
modePrefix = " "
if pomodoro.Paused {
modePrefix = " "
}
minutes := pomodoro.TimeLeft / 60
seconds := pomodoro.TimeLeft % 60
2024-10-22 11:13:41 +00:00
timerOutput = fmt.Sprintf("⏳ %02d:%02d", minutes, seconds)
}
output += fmt.Sprintf("Session: %d/%d\n",
pomodoro.Session,
pomodoro.Settings.Sessions,
)
output += fmt.Sprintf("%s %s\n", modePrefix, pomodoro.Mode)
output += fmt.Sprintf(timerOutput)
return output
2024-10-22 11:13:41 +00:00
}