From 82faa1d536d8a621d537c5daf133a5fbec03015b Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Sat, 15 Jun 2019 14:25:45 +0200 Subject: [PATCH] fix(cmd): configPath variable --- cmd/cmd.go | 2 +- cmd/daemon/daemon.go | 11 ++++++++--- cmd/humidity/get.go | 9 +++------ cmd/humidity/humidity.go | 6 +++--- cmd/temperature/list.go | 2 +- cmd/temperature/read.go | 2 +- cmd/temperature/temperature.go | 6 +++--- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 6102c7f..1220390 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -53,7 +53,7 @@ func Execute(version string) { rootCmd.Version = version rootCmd.PersistentFlags().StringVar(&configPath, "config", "/etc/flucky/config.json", "Config file") - // humidity.InitCmd(rootCmd, configDir) + // humidity.InitCmd(rootCmd, configPath) sensor.InitCmd(rootCmd, configPath) temperature.InitCmd(rootCmd, configPath) rootCmd.Execute() diff --git a/cmd/daemon/daemon.go b/cmd/daemon/daemon.go index c2253fa..550724f 100644 --- a/cmd/daemon/daemon.go +++ b/cmd/daemon/daemon.go @@ -4,18 +4,23 @@ import ( "github.com/spf13/cobra" ) -var configDir string +var configPath string var daemonCmd = &cobra.Command{ Use: "daemon", Short: "Read continuously data from all enabled sensors", Run: func(cmd *cobra.Command, args []string) { + // read configuration + // cnf, err := config.Read(configPath) + // if err != nil { + // log.Fatalln(err) + // } }, } -func InitCmd(cmd *cobra.Command, cnf string) { - configDir = cnf +func InitCmd(cmd *cobra.Command, cnfPath string) { + configPath = cnfPath cmd.AddCommand(daemonCmd) diff --git a/cmd/humidity/get.go b/cmd/humidity/get.go index 5bca5b0..2770d50 100644 --- a/cmd/humidity/get.go +++ b/cmd/humidity/get.go @@ -1,10 +1,7 @@ package humidity import ( - "log" - "github.com/spf13/cobra" - "github.com/volker-raschek/flucky/pkg/humidity" ) var follow, push bool @@ -14,9 +11,9 @@ var getHumidityCmd = &cobra.Command{ Short: "get humidity from sensor", Run: func(cmd *cobra.Command, args []string) { - if err := humidity.Get(); err != nil { - log.Fatal(err) - } + // if err := humidity.Get(); err != nil { + // log.Fatal(err) + // } }, } diff --git a/cmd/humidity/humidity.go b/cmd/humidity/humidity.go index 5d6de3d..6bb5076 100644 --- a/cmd/humidity/humidity.go +++ b/cmd/humidity/humidity.go @@ -4,7 +4,7 @@ import ( "github.com/spf13/cobra" ) -var configDir string +var configPath string var humidityCmd = &cobra.Command{ Use: "humidity", @@ -12,8 +12,8 @@ var humidityCmd = &cobra.Command{ } // Execute a -func InitCmd(cmd *cobra.Command, cnf string) { - configDir = cnf +func InitCmd(cmd *cobra.Command, cnfPath string) { + configPath = cnfPath cmd.AddCommand(humidityCmd) diff --git a/cmd/temperature/list.go b/cmd/temperature/list.go index 81fbf9f..bdd0877 100644 --- a/cmd/temperature/list.go +++ b/cmd/temperature/list.go @@ -18,7 +18,7 @@ var listTemperatureCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { // read configuration - cnf, err := config.Read(cnfPath) + cnf, err := config.Read(configPath) if err != nil { log.Fatalln(err) } diff --git a/cmd/temperature/read.go b/cmd/temperature/read.go index f24caa2..d24daf9 100644 --- a/cmd/temperature/read.go +++ b/cmd/temperature/read.go @@ -22,7 +22,7 @@ var readTemperatureCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { // read configuration - cnf, err := config.Read(cnfPath) + cnf, err := config.Read(configPath) if err != nil { log.Fatalln(err) } diff --git a/cmd/temperature/temperature.go b/cmd/temperature/temperature.go index 4b6a2ed..deaf3cd 100644 --- a/cmd/temperature/temperature.go +++ b/cmd/temperature/temperature.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -var cnfPath string +var configPath string var temperatureCmd = &cobra.Command{ Use: "temperature", @@ -15,8 +15,8 @@ var temperatureCmd = &cobra.Command{ } // Execute a -func InitCmd(cmd *cobra.Command, configPath string) { - cnfPath = configPath +func InitCmd(cmd *cobra.Command, cnfPath string) { + configPath = cnfPath cmd.AddCommand(temperatureCmd) }