sampler-fork/data/item.go

25 lines
424 B
Go
Raw Normal View History

2019-01-31 23:40:05 +00:00
package data
import (
ui "github.com/sqshq/termui"
2019-01-31 23:40:05 +00:00
"os/exec"
"strings"
)
type Item struct {
2019-02-17 23:00:00 +00:00
Label *string `yaml:"label,omitempty"`
Script string `yaml:"script"`
Color *ui.Color `yaml:"color,omitempty"`
2019-01-31 23:40:05 +00:00
}
func (i *Item) nextValue() (value string, err error) {
2019-01-31 23:40:05 +00:00
output, err := exec.Command("sh", "-c", i.Script).Output()
2019-01-31 23:40:05 +00:00
if err != nil {
return "", err
}
return strings.TrimSpace(string(output)), nil
}