1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Add Makefile support for 'make install' and version info

This commit is contained in:
Chris Cummer 2018-04-23 17:35:14 -07:00
parent 34dcdbbe66
commit 5a31de74fe
4 changed files with 39 additions and 14 deletions

View File

@ -0,0 +1,2 @@
install:
go install -ldflags="-X main.version=$(shell git describe --always --long --dirty)"

View File

@ -1,7 +1,7 @@
package status
import (
//"fmt"
"fmt"
//"sort"
//"strings"
"time"
@ -17,12 +17,14 @@ type Widget struct {
wtf.TextWidget
Current int
Version string
}
func NewWidget() *Widget {
func NewWidget(version string) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(" 🎉 Status ", "status"),
Current: 0,
Version: version,
}
return &widget
@ -35,14 +37,14 @@ func (widget *Widget) Refresh() {
return
}
//_, _, w, _ := widget.View.GetInnerRect()
_, _, w, _ := widget.View.GetInnerRect()
//widget.View.Clear()
//fmt.Fprintf(
//widget.View,
//fmt.Sprintf("\n%%%ds", w-1),
//widget.timezones(),
//)
widget.View.Clear()
fmt.Fprintf(
widget.View,
fmt.Sprintf("\n%%%ds", w-1),
widget.Version,
)
widget.RefreshedAt = time.Now()
}

View File

@ -1,8 +1,6 @@
package todo
import (
"fmt"
)
import ()
type List struct {
Items []*Item

27
wtf.go
View File

@ -2,9 +2,9 @@ package main
import (
"flag"
"fmt"
"os"
"time"
//"math/rand"
"github.com/gdamore/tcell"
"github.com/olebedev/config"
@ -99,19 +99,42 @@ func refreshAllModules() {
}
}
func versionInfo() {
fmt.Printf("Version: %s\n", version)
os.Exit(0)
}
var result = wtf.CreateConfigDir()
var Config *config.Config
var FocusTracker wtf.FocusTracker
var Widgets []wtf.TextViewer
var version = "dev"
/* -------------------- Main -------------------- */
func main() {
// Optional argument to accept path to a config file
configFile := flag.String("config", "~/.wtf/config.yml", "Path to config file")
flagVersion := flag.Bool("version", false, "Show version info")
flag.Parse()
if *flagVersion {
versionInfo()
}
// If we're just displaying the version, exit early
args := flag.Args()
cmd := args[0]
switch cmd {
case "help", "--help", "-h":
os.Exit(0)
case "version", "--version":
versionInfo()
}
Config = wtf.LoadConfigFile(*configFile)
wtf.Config = Config
@ -140,7 +163,7 @@ func main() {
newrelic.NewWidget(),
opsgenie.NewWidget(),
security.NewWidget(),
status.NewWidget(),
status.NewWidget(version),
textfile.NewWidget(),
todo.NewWidget(),
weather.NewWidget(),