/* Pominal Copyright (C) 2020 Daniel Anglin This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package main import ( "flag" "log" "os" "time" "github.com/rivo/tview" ) func main() { var ( workTime string shortBreakTime string longBreakTime string maxWorkSessions int printVersion bool ) flag.StringVar(&workTime, "work", "25m", "sets the timer for your work session.") flag.StringVar(&shortBreakTime, "short-break", "5m", "sets the timer for your short break.") flag.StringVar(&longBreakTime, "long-break", "20m", "sets the timer for your long break.") flag.IntVar(&maxWorkSessions, "max-work-sessions", 4, "sets the maximum number of work cycles to complete before taking a long break.") flag.BoolVar(&printVersion, "version", false, "print version and exit.") flag.Parse() if printVersion { Version() os.Exit(0) } w, err := time.ParseDuration(workTime) if err != nil { log.Fatalf("ERROR: Unable to set the work timer. %s", err.Error()) } s, err := time.ParseDuration(shortBreakTime) if err != nil { log.Fatalf("ERROR: Unable to set the work timer. %s", err.Error()) } l, err := time.ParseDuration(longBreakTime) if err != nil { log.Fatalf("ERROR: Unable to set the work timer. %s", err.Error()) } pominal := NewPominal( w.Seconds(), s.Seconds(), l.Seconds(), maxWorkSessions, ) app := tview.NewApplication() infoUI := newInfoUI() timerUI := newTimerUI(app) flex := newFlex(infoUI, timerUI) go pominal.Run(infoUI, timerUI) if err := app.SetRoot(flex, false).SetFocus(flex).Run(); err != nil { panic(err) } }