PKGBUILD/cmd/temperature/log.go

38 lines
695 B
Go

package temperature
import (
"fmt"
"log"
"os"
"github.com/spf13/cobra"
"github.com/volker-raschek/flucky/pkg/cli"
"github.com/volker-raschek/flucky/pkg/config"
)
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)
}