feat: temperature print log values

This commit is contained in:
Markus Pesch 2019-03-04 17:50:23 +01:00
parent 64368ff69d
commit d78b32e14d
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982

38
cmd/temperature/log.go Normal file
View File

@ -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)
}