PKGBUILD/cmd/temperature/list.go

41 lines
742 B
Go
Raw Normal View History

package temperature
import (
"fmt"
"log"
"os"
2019-06-15 13:58:41 +00:00
"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(configFile)
if err != nil {
log.Fatalln(err)
}
logfile := logfile.New(cnf)
measuredValues, err := logfile.Read()
if err != nil {
log.Fatalln(err)
}
cli.PrintMeasuredValues(measuredValues, cnf, os.Stdout)
},
}
func init() {
temperatureCmd.AddCommand(listTemperatureCmd)
}