PKGBUILD/cmd/temperature/read.go

42 lines
864 B
Go
Raw Normal View History

2019-02-24 21:46:36 +00:00
package temperature
import (
"log"
"os"
"git.cryptic.systems/fh-trier/go-flucky/pkg/cli"
"git.cryptic.systems/fh-trier/go-flucky/pkg/config"
"git.cryptic.systems/fh-trier/go-flucky/pkg/sensor"
"github.com/spf13/cobra"
)
var follow, push bool
var readTemperatureCmd = &cobra.Command{
Use: "read",
Short: "read temperature from sensor",
Run: func(cmd *cobra.Command, args []string) {
// read configuration
fc, err := config.Read(cfg)
if err != nil {
log.Fatalln(err)
}
// FIXME:
// add sensor entry to list
temperatures, err := sensor.ReadTemperatures(fc.GetTemperatureSensors())
if err != nil {
log.Fatalln(err)
}
cli.PrintTemperatures(temperatures, fc, os.Stdout)
},
}
func init() {
temperatureCmd.AddCommand(readTemperatureCmd)
readTemperatureCmd.Flags().BoolVarP(&follow, "follow", "f", false, "Follow output")
}