From d78b32e14d49e1fc8f4fb294e00d043938de845f Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Mon, 4 Mar 2019 17:50:23 +0100 Subject: [PATCH] feat: temperature print log values --- cmd/temperature/log.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cmd/temperature/log.go diff --git a/cmd/temperature/log.go b/cmd/temperature/log.go new file mode 100644 index 0000000..da23d26 --- /dev/null +++ b/cmd/temperature/log.go @@ -0,0 +1,38 @@ +package temperature + +import ( + "fmt" + "log" + "os" + + "git.cryptic.systems/fh-trier/go-flucky/pkg/cli" + + "git.cryptic.systems/fh-trier/go-flucky/pkg/config" + "github.com/spf13/cobra" +) + +var logTemperatureCmd = &cobra.Command{ + Use: "log", + Short: "print temperature logs", + Example: fmt.Sprintf("flucky temperature logs"), + Run: func(cmd *cobra.Command, args []string) { + + // read configuration + fc, err := config.Read(cfg) + if err != nil { + log.Fatalln(err) + } + + temperatures, err := fc.FileLogger.GetTemperatures(nil, nil, args) + if err != nil { + log.Fatalln(err) + } + + cli.PrintTemperatures(temperatures, fc, os.Stdout) + + }, +} + +func init() { + temperatureCmd.AddCommand(logTemperatureCmd) +}