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