package temperature import ( "fmt" "log" "os" "github.com/go-flucky/flucky/pkg/cli" "github.com/go-flucky/flucky/pkg/config" "github.com/go-flucky/flucky/pkg/logfile" "github.com/spf13/cobra" ) var listTemperatureCmd = &cobra.Command{ Use: "list", Short: "print temperatures", Example: fmt.Sprintf("flucky temperature logs"), Run: func(cmd *cobra.Command, args []string) { // read configuration 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) }