42 lines
864 B
Go
42 lines
864 B
Go
|
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")
|
||
|
}
|