fix(cmd): configPath variable

This commit is contained in:
Markus Pesch 2019-06-15 14:25:45 +02:00
parent 258ac998be
commit 82faa1d536
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
7 changed files with 20 additions and 18 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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)
// }
},
}

View File

@ -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)

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}