feat: temperature print log values
This commit is contained in:
parent
64368ff69d
commit
d78b32e14d
38
cmd/temperature/log.go
Normal file
38
cmd/temperature/log.go
Normal 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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user