1
0
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:
Chris Cummer 2018-04-09 13:19:16 -07:00 committed by Chris Cummer
parent cc4b5714f0
commit 7072820967
4 changed files with 35 additions and 3 deletions

View File

@ -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

View File

@ -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),
)

5
wtf.go
View File

@ -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)

View File

@ -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)
}