2024-10-31 07:37:50 +01:00
|
|
|
package helper
|
2024-10-22 13:13:41 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-10-31 07:37:50 +01:00
|
|
|
|
|
|
|
"github.com/alecthomas/colour"
|
2024-10-27 21:34:53 +01:00
|
|
|
|
|
|
|
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
2024-10-22 13:13:41 +02:00
|
|
|
)
|
|
|
|
|
2024-10-31 07:37:50 +01:00
|
|
|
// Return terminal output based on the passed ServerMessage
|
|
|
|
func TerminalOutput(pomodoro GoTomato.ServerMessage) string {
|
2024-10-27 21:32:57 +01:00
|
|
|
var (
|
2024-10-31 07:37:50 +01:00
|
|
|
output string
|
|
|
|
|
2024-10-27 21:32:57 +01:00
|
|
|
modePrefix string
|
|
|
|
timerOutput string
|
|
|
|
)
|
2024-10-22 13:13:41 +02:00
|
|
|
|
2024-10-24 19:16:57 +02:00
|
|
|
// header
|
2024-10-31 07:37:50 +01:00
|
|
|
output += colour.Sprintf("^D^4Work: %d ◊ Break: %d ◊ Longbreak: %d^R\n\n",
|
2024-10-28 07:56:37 +01:00
|
|
|
pomodoro.Settings.Work/60,
|
|
|
|
pomodoro.Settings.ShortBreak/60,
|
|
|
|
pomodoro.Settings.LongBreak/60,
|
2024-10-22 13:13:41 +02:00
|
|
|
)
|
|
|
|
|
2024-10-24 19:16:57 +02:00
|
|
|
//body
|
2024-10-23 13:48:16 +02:00
|
|
|
switch pomodoro.Mode {
|
2024-10-22 13:13:41 +02:00
|
|
|
case "Idle":
|
2024-10-24 19:16:57 +02:00
|
|
|
modePrefix = " "
|
2024-10-22 13:13:41 +02:00
|
|
|
timerOutput = ""
|
|
|
|
default:
|
2024-10-24 19:16:57 +02:00
|
|
|
modePrefix = " "
|
|
|
|
if pomodoro.Paused {
|
|
|
|
modePrefix = " "
|
|
|
|
}
|
2024-10-23 13:48:16 +02:00
|
|
|
minutes := pomodoro.TimeLeft / 60
|
|
|
|
seconds := pomodoro.TimeLeft % 60
|
2024-10-22 13:13:41 +02:00
|
|
|
|
|
|
|
timerOutput = fmt.Sprintf("⏳ %02d:%02d", minutes, seconds)
|
|
|
|
}
|
|
|
|
|
2024-10-31 07:37:50 +01:00
|
|
|
output += fmt.Sprintf("Session: %d/%d\n",
|
2024-10-24 19:16:57 +02:00
|
|
|
pomodoro.Session,
|
2024-10-28 07:56:37 +01:00
|
|
|
pomodoro.Settings.Sessions,
|
2024-10-24 19:16:57 +02:00
|
|
|
)
|
2024-10-31 07:37:50 +01:00
|
|
|
output += fmt.Sprintf("%s %s\n", modePrefix, pomodoro.Mode)
|
|
|
|
output += fmt.Sprintf(timerOutput)
|
2024-10-23 13:51:19 +02:00
|
|
|
|
2024-10-31 07:37:50 +01:00
|
|
|
return output
|
2024-10-22 13:13:41 +02:00
|
|
|
}
|