-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
44 lines (39 loc) · 1.02 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"os"
"strconv"
"time"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
)
const defaultWorkDurationInMins = 25
const defaultRestDurationInMins = 5
func main() {
a := app.New()
win := a.NewWindow("Pomodoro")
clock := widget.NewLabel("")
workDurationInMins := defaultWorkDurationInMins
restDurationInMins := defaultRestDurationInMins
if len(os.Args) != 3 {
fmt.Println("Incorrect number of arguments, using default values of 25minutes working and 5minutes resting")
}
if len(os.Args) == 3 {
wdur, err1 := strconv.Atoi(os.Args[1])
rdur, err2 := strconv.Atoi(os.Args[2])
workDurationInMins = wdur
restDurationInMins = rdur
if err1 != nil || err2 != nil {
fmt.Println("Problem setting interval values, using default values of 25minutes working and 5minutes resting")
}
}
t := timer{
start: time.Now(),
inWorkMode: true,
workDuration: workDurationInMins * 60,
restDuration: restDurationInMins * 60,
}
go t.updateTime(clock)
win.SetContent(clock)
win.ShowAndRun()
}