PKGBUILD/cmd/temperature/list.go

39 lines
761 B
Go
Raw Normal View History

package temperature
import (
"fmt"
"log"
"os"
"github.com/spf13/cobra"
"github.com/volker-raschek/flucky/pkg/cli"
"github.com/volker-raschek/flucky/pkg/config"
"github.com/volker-raschek/flucky/pkg/logfile"
)
var listTemperatureCmd = &cobra.Command{
Use: "list",
Short: "print temperatures",
Example: fmt.Sprintf("flucky temperature logs"),
Run: func(cmd *cobra.Command, args []string) {
// read configuration
2019-06-15 12:25:45 +00:00
cnf, err := config.Read(configPath)
if err != nil {
log.Fatalln(err)
}
temperatures, err := logfile.ReadTemperatures(cnf.Device.TemperatureLogfile)
if err != nil {
log.Fatalln(err)
}
cli.PrintTemperatures(temperatures, cnf, os.Stdout)
},
}
func init() {
temperatureCmd.AddCommand(listTemperatureCmd)
}