From 258ac998be5af00dd4873f9d63839224e2287a51 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Sat, 15 Jun 2019 14:02:35 +0200 Subject: [PATCH] fix(cmd/temperature): list temperatures --- cmd/temperature/list.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/temperature/list.go b/cmd/temperature/list.go index b2de2e2..81fbf9f 100644 --- a/cmd/temperature/list.go +++ b/cmd/temperature/list.go @@ -2,8 +2,13 @@ package temperature import ( "fmt" + "log" + "os" "github.com/spf13/cobra" + "github.com/volker-raschek/flucky/pkg/cli" + "github.com/volker-raschek/flucky/pkg/config" + "github.com/volker-raschek/flucky/pkg/logfile" ) var listTemperatureCmd = &cobra.Command{ @@ -13,12 +18,17 @@ var listTemperatureCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { // read configuration - // fc, err := config.Read(cnfPath) - // if err != nil { - // list.Fatalln(err) - // } + cnf, err := config.Read(cnfPath) + if err != nil { + log.Fatalln(err) + } - //cli.PrintTemperatures(temperatures, fc, os.Stdout) + temperatures, err := logfile.ReadTemperatures(cnf.Device.TemperatureLogfile) + if err != nil { + log.Fatalln(err) + } + + cli.PrintTemperatures(temperatures, cnf, os.Stdout) }, }