diff --git a/config.yml b/config.yml index 358bd058..b7c6f84a 100644 --- a/config.yml +++ b/config.yml @@ -1,4 +1,12 @@ 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 bamboohr: enabled: true diff --git a/newrelic/widget.go b/newrelic/widget.go index 7a1695e2..83f09cd8 100644 --- a/newrelic/widget.go +++ b/newrelic/widget.go @@ -68,9 +68,15 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string { for _, deploy := range deploys { if (deploy.Revision != "") && wtf.Exclude(revisions, deploy.Revision) { + lineColor := "white" + if wtf.IsToday(deploy.Timestamp) { + lineColor = "cornflowerblue" + } + str = str + fmt.Sprintf( - " [green]%s[white] %s %-16s\n", + " [green]%s[%s] %s %-16s[white]\n", deploy.Revision[0:8], + lineColor, deploy.Timestamp.Format("Jan 02, 15:04 MST"), wtf.NameFromEmail(deploy.User), ) diff --git a/wtf.go b/wtf.go index 5e3140db..adfd7783 100644 --- a/wtf.go +++ b/wtf.go @@ -57,6 +57,7 @@ var Config = wtf.LoadConfigFile() func main() { wtf.Config = Config + // TODO: Really need to generalize all of these. This don't scale bamboohr.Config = Config bamboo := bamboohr.NewWidget() go wtf.Schedule(bamboo) @@ -98,8 +99,8 @@ func main() { go wtf.Schedule(weather) grid := tview.NewGrid() - grid.SetRows(10, 10, 10, 10, 10, 4) // How _high_ the row is, in terminal rows - grid.SetColumns(37, 37, 37, 37, 37) // How _wide_ the column is, in terminal columns + grid.SetColumns(wtf.ToInts(Config.UList("wtf.grid.columns"))...) + grid.SetRows(wtf.ToInts(Config.UList("wtf.grid.rows"))...) grid.SetBorder(false) addToApp(grid, bamboo) diff --git a/wtf/utils.go b/wtf/utils.go index 7d185504..a46dffa7 100644 --- a/wtf/utils.go +++ b/wtf/utils.go @@ -44,6 +44,14 @@ func Exclude(strs []string, val string) bool { 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 { parts := strings.Split(email, "@") return strings.Title(strings.Replace(parts[0], ".", " ", -1)) @@ -69,6 +77,15 @@ func Today() string { 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 { return time.Unix(unix, 0) }