feat: show versions
This commit is contained in:
parent
0cd7dab556
commit
4daa57de82
3 changed files with 27 additions and 2 deletions
|
@ -19,7 +19,7 @@ builds:
|
|||
- linux
|
||||
id: pominal-build
|
||||
ldflags:
|
||||
- s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.goversion={{.Env.GOVERSION}}
|
||||
- "-s -w -X main.version={{ .Version }} -X main.commit={{ .ShortCommit }} -X main.date={{ .Date }} -X main.goversion={{ .Env.GOVERSION }}"
|
||||
|
||||
archives:
|
||||
- files:
|
||||
|
|
7
main.go
7
main.go
|
@ -40,6 +40,7 @@ var (
|
|||
shortBreakTimer string
|
||||
longBreakTimer string
|
||||
maxWorkCycles int
|
||||
printVersion bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -47,6 +48,7 @@ func init() {
|
|||
flag.StringVar(&shortBreakTimer, "short-break-timer", "5m", "sets the timer for your short break.")
|
||||
flag.StringVar(&longBreakTimer, "long-break-timer", "20m", "sets the timer for your long break.")
|
||||
flag.IntVar(&maxWorkCycles, "max-work-cycles", 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()
|
||||
}
|
||||
|
||||
|
@ -63,6 +65,11 @@ type Pominal struct {
|
|||
|
||||
func main() {
|
||||
|
||||
if printVersion {
|
||||
Version()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
workTimeDuration, err := time.ParseDuration(workTimer)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: Unable to set the work timer. %s", err.Error())
|
||||
|
|
20
version.go
20
version.go
|
@ -1,3 +1,21 @@
|
|||
/*
|
||||
Pominal
|
||||
Copyright (C) 2019 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 "fmt"
|
||||
|
@ -10,5 +28,5 @@ var (
|
|||
)
|
||||
|
||||
func Version() {
|
||||
fmt.Printf("Version: %s\nCommit: %s\nGo Version: %s\nDate: %s", version, commit, goversion, date)
|
||||
fmt.Printf("Pominal\n\nVersion: %s\nCommit: %s\nGo Version: %s\nDate: %s", version, commit, goversion, date)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue