Dan Anglin
ec84a11036
This commit adds an install target in the Makefile to install Pominal on the user's system. The default installation path is /usr/local/bin but this can be configured by overriding the INSTALL_PREFIX variable. Changes include: - cleaning up .gitignore - adding workflow to .gitlab-ci.yml - bumping Go version in .gitlab-ci.yml - excluding main.go for gochecknoglobals - adding copyright notice in Makefile - adding install and uninstall targets in Makefile - adding installation instructions in the README - adding a config.mk file for make arguments - updating Pominal to specify where the icon is installed
94 lines
2.6 KiB
Go
94 lines
2.6 KiB
Go
/*
|
|
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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/rivo/tview"
|
|
)
|
|
|
|
var (
|
|
version string
|
|
installPrefix string
|
|
)
|
|
|
|
const (
|
|
workTimerLabel string = "Work"
|
|
shortBreakTimerLabel string = "Short break"
|
|
longBreakTimerLabel string = "Long break"
|
|
defaultWorkTime string = "25m"
|
|
defaultShortBreakTime string = "5m"
|
|
defaultLongBreakTime string = "20m"
|
|
defaultMaxWorkSessions int = 4
|
|
defaultNotificationMsgFmt string = "%s session is now running."
|
|
minimumSessionTime float64 = 60
|
|
)
|
|
|
|
func main() {
|
|
var (
|
|
workTime string
|
|
shortBreakTime string
|
|
longBreakTime string
|
|
maxWorkSessions int
|
|
printVersion bool
|
|
configFilePath string
|
|
)
|
|
|
|
flag.StringVar(&workTime, "work", "", "sets the timer for your work session.")
|
|
flag.StringVar(&shortBreakTime, "short-break", "", "sets the timer for your short break.")
|
|
flag.StringVar(&longBreakTime, "long-break", "", "sets the timer for your long break.")
|
|
flag.IntVar(&maxWorkSessions, "max-work-sessions", 0, "sets the maximum number of work cycles to complete before taking a long break.")
|
|
flag.BoolVar(&printVersion, "version", false, "print version and exit.")
|
|
flag.StringVar(&configFilePath, "config", "", "the path to your Pominal configuration file.")
|
|
flag.Parse()
|
|
|
|
if printVersion {
|
|
Version()
|
|
os.Exit(0)
|
|
}
|
|
|
|
config, err := newPominalConfig(configFilePath, workTime, shortBreakTime, longBreakTime, maxWorkSessions)
|
|
if err != nil {
|
|
log.Fatalf("ERROR: Unable to create the Pominal configuration. %s", err.Error())
|
|
}
|
|
|
|
pominal, err := newPominal(config)
|
|
if err != nil {
|
|
log.Fatalf("ERROR: Unable to create Pominal. %s", err.Error())
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
func Version() {
|
|
fmt.Printf("Pominal version %s\n", version)
|
|
}
|