mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Column and row definitions into the config file. No need to compile to change sizes
This commit is contained in:
parent
cc4b5714f0
commit
7072820967
@ -1,4 +1,12 @@
|
|||||||
wtf:
|
wtf:
|
||||||
|
grid:
|
||||||
|
# How _wide_ the columns are, in terminal characters. In this case we have
|
||||||
|
# five columns, each of which are 37 characters wide
|
||||||
|
columns: [37, 37, 37, 37, 37]
|
||||||
|
|
||||||
|
# How _high_ the rows are, in terminal lines. In this case we have five rows
|
||||||
|
# that support ten line of text, and one of four
|
||||||
|
rows: [10, 10, 10, 10, 10, 4]
|
||||||
refreshInterval: 1
|
refreshInterval: 1
|
||||||
bamboohr:
|
bamboohr:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
@ -68,9 +68,15 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
|
|||||||
|
|
||||||
for _, deploy := range deploys {
|
for _, deploy := range deploys {
|
||||||
if (deploy.Revision != "") && wtf.Exclude(revisions, deploy.Revision) {
|
if (deploy.Revision != "") && wtf.Exclude(revisions, deploy.Revision) {
|
||||||
|
lineColor := "white"
|
||||||
|
if wtf.IsToday(deploy.Timestamp) {
|
||||||
|
lineColor = "cornflowerblue"
|
||||||
|
}
|
||||||
|
|
||||||
str = str + fmt.Sprintf(
|
str = str + fmt.Sprintf(
|
||||||
" [green]%s[white] %s %-16s\n",
|
" [green]%s[%s] %s %-16s[white]\n",
|
||||||
deploy.Revision[0:8],
|
deploy.Revision[0:8],
|
||||||
|
lineColor,
|
||||||
deploy.Timestamp.Format("Jan 02, 15:04 MST"),
|
deploy.Timestamp.Format("Jan 02, 15:04 MST"),
|
||||||
wtf.NameFromEmail(deploy.User),
|
wtf.NameFromEmail(deploy.User),
|
||||||
)
|
)
|
||||||
|
5
wtf.go
5
wtf.go
@ -57,6 +57,7 @@ var Config = wtf.LoadConfigFile()
|
|||||||
func main() {
|
func main() {
|
||||||
wtf.Config = Config
|
wtf.Config = Config
|
||||||
|
|
||||||
|
// TODO: Really need to generalize all of these. This don't scale
|
||||||
bamboohr.Config = Config
|
bamboohr.Config = Config
|
||||||
bamboo := bamboohr.NewWidget()
|
bamboo := bamboohr.NewWidget()
|
||||||
go wtf.Schedule(bamboo)
|
go wtf.Schedule(bamboo)
|
||||||
@ -98,8 +99,8 @@ func main() {
|
|||||||
go wtf.Schedule(weather)
|
go wtf.Schedule(weather)
|
||||||
|
|
||||||
grid := tview.NewGrid()
|
grid := tview.NewGrid()
|
||||||
grid.SetRows(10, 10, 10, 10, 10, 4) // How _high_ the row is, in terminal rows
|
grid.SetColumns(wtf.ToInts(Config.UList("wtf.grid.columns"))...)
|
||||||
grid.SetColumns(37, 37, 37, 37, 37) // How _wide_ the column is, in terminal columns
|
grid.SetRows(wtf.ToInts(Config.UList("wtf.grid.rows"))...)
|
||||||
grid.SetBorder(false)
|
grid.SetBorder(false)
|
||||||
|
|
||||||
addToApp(grid, bamboo)
|
addToApp(grid, bamboo)
|
||||||
|
17
wtf/utils.go
17
wtf/utils.go
@ -44,6 +44,14 @@ func Exclude(strs []string, val string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsToday(date time.Time) bool {
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
return (date.Year() == now.Year()) &&
|
||||||
|
(date.Month() == now.Month()) &&
|
||||||
|
(date.Day() == now.Day())
|
||||||
|
}
|
||||||
|
|
||||||
func NameFromEmail(email string) string {
|
func NameFromEmail(email string) string {
|
||||||
parts := strings.Split(email, "@")
|
parts := strings.Split(email, "@")
|
||||||
return strings.Title(strings.Replace(parts[0], ".", " ", -1))
|
return strings.Title(strings.Replace(parts[0], ".", " ", -1))
|
||||||
@ -69,6 +77,15 @@ func Today() string {
|
|||||||
return localNow.Format("2006-01-02")
|
return localNow.Format("2006-01-02")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ToInts(slice []interface{}) []int {
|
||||||
|
results := []int{}
|
||||||
|
for _, val := range slice {
|
||||||
|
results = append(results, val.(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
func UnixTime(unix int64) time.Time {
|
func UnixTime(unix int64) time.Time {
|
||||||
return time.Unix(unix, 0)
|
return time.Unix(unix, 0)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user