PKGBUILD/cmd/temperature/log.go

38 lines
707 B
Go

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