fix(cmd): configPath variable
This commit is contained in:
		| @@ -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() | ||||
|   | ||||
| @@ -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) | ||||
|  | ||||
|   | ||||
| @@ -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) | ||||
| 		// } | ||||
|  | ||||
| 	}, | ||||
| } | ||||
|   | ||||
| @@ -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) | ||||
|  | ||||
|   | ||||
| @@ -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) | ||||
| 		} | ||||
|   | ||||
| @@ -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) | ||||
| 		} | ||||
|   | ||||
| @@ -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) | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user