Markus Pesch
dbef4f8241
changes: - Only one storage endpoint can be defined. This consists of a URL which can be used to specify whether the data is to be stored in a file or in a database.
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package humidity
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/go-flucky/flucky/pkg/storage"
|
|
"github.com/go-flucky/flucky/pkg/types"
|
|
|
|
"github.com/go-flucky/flucky/pkg/cli"
|
|
"github.com/go-flucky/flucky/pkg/config"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var listTemperatureCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: "List humidity values from different or specified sensors by arguments",
|
|
Example: fmt.Sprintf("flucky humidity logs"),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
// read configuration
|
|
cnf, err := config.Read(*configFile)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
ctx := context.Background()
|
|
storageEndpoint, err := cnf.GetStorageEndpointURL()
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
measuredValues, err := storage.Read(ctx, storageEndpoint)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
measuredValues = types.SelectMeasuredValues(types.MeasuredValueTypeHumidity, measuredValues)
|
|
|
|
cli.PrintMeasuredValues(measuredValues, cnf, os.Stdout)
|
|
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
humidityCmd.AddCommand(listTemperatureCmd)
|
|
}
|