refac(pkg/sensor): temperature measurement unit
This commit is contained in:
		@@ -7,13 +7,15 @@ import (
 | 
			
		||||
	"github.com/go-flucky/flucky/pkg/config"
 | 
			
		||||
	"github.com/go-flucky/flucky/pkg/daemon"
 | 
			
		||||
	"github.com/go-flucky/flucky/pkg/logger"
 | 
			
		||||
	"github.com/go-flucky/flucky/pkg/sensor"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var cleanCacheInterval string
 | 
			
		||||
var compression bool
 | 
			
		||||
var configFile string
 | 
			
		||||
var cleanCacheInterval string
 | 
			
		||||
var round float64
 | 
			
		||||
var temperatureUnit string
 | 
			
		||||
 | 
			
		||||
var daemonCmd = &cobra.Command{
 | 
			
		||||
	Use:   "daemon",
 | 
			
		||||
@@ -32,7 +34,12 @@ var daemonCmd = &cobra.Command{
 | 
			
		||||
 | 
			
		||||
		logger := logger.NewDefaultLogger(logger.LogLevelDebug, false)
 | 
			
		||||
 | 
			
		||||
		daemon.Start(cnf, duration, compression, round, logger)
 | 
			
		||||
		measurementUnit, err := sensor.SelectTemperatureMeasurementUnit(temperatureUnit)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatalf("Can not parse temperature unit: %v", temperatureUnit)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		daemon.Start(cnf, duration, compression, measurementUnit, round, logger)
 | 
			
		||||
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
@@ -43,4 +50,5 @@ func InitCmd(cmd *cobra.Command, cnfFile string) {
 | 
			
		||||
	daemonCmd.Flags().BoolVar(&compression, "compression", true, "Compress measured values")
 | 
			
		||||
	daemonCmd.Flags().StringVar(&cleanCacheInterval, "clean-cache-interval", "5m", "Minute intervall to clean cache and write measured values into logfile")
 | 
			
		||||
	daemonCmd.Flags().Float64Var(&round, "round", 0.25, "Round values. The value 0 deactivates the function")
 | 
			
		||||
	daemonCmd.Flags().StringVar(&temperatureUnit, "temperature-unit", "celsius", "Temperature unit")
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user