fix(cmd): configPath variable
This commit is contained in:
parent
258ac998be
commit
82faa1d536
@ -53,7 +53,7 @@ func Execute(version string) {
|
|||||||
rootCmd.Version = version
|
rootCmd.Version = version
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVar(&configPath, "config", "/etc/flucky/config.json", "Config file")
|
rootCmd.PersistentFlags().StringVar(&configPath, "config", "/etc/flucky/config.json", "Config file")
|
||||||
// humidity.InitCmd(rootCmd, configDir)
|
// humidity.InitCmd(rootCmd, configPath)
|
||||||
sensor.InitCmd(rootCmd, configPath)
|
sensor.InitCmd(rootCmd, configPath)
|
||||||
temperature.InitCmd(rootCmd, configPath)
|
temperature.InitCmd(rootCmd, configPath)
|
||||||
rootCmd.Execute()
|
rootCmd.Execute()
|
||||||
|
@ -4,18 +4,23 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var configDir string
|
var configPath string
|
||||||
|
|
||||||
var daemonCmd = &cobra.Command{
|
var daemonCmd = &cobra.Command{
|
||||||
Use: "daemon",
|
Use: "daemon",
|
||||||
Short: "Read continuously data from all enabled sensors",
|
Short: "Read continuously data from all enabled sensors",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
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) {
|
func InitCmd(cmd *cobra.Command, cnfPath string) {
|
||||||
configDir = cnf
|
configPath = cnfPath
|
||||||
|
|
||||||
cmd.AddCommand(daemonCmd)
|
cmd.AddCommand(daemonCmd)
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package humidity
|
package humidity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/volker-raschek/flucky/pkg/humidity"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var follow, push bool
|
var follow, push bool
|
||||||
@ -14,9 +11,9 @@ var getHumidityCmd = &cobra.Command{
|
|||||||
Short: "get humidity from sensor",
|
Short: "get humidity from sensor",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
if err := humidity.Get(); err != nil {
|
// if err := humidity.Get(); err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var configDir string
|
var configPath string
|
||||||
|
|
||||||
var humidityCmd = &cobra.Command{
|
var humidityCmd = &cobra.Command{
|
||||||
Use: "humidity",
|
Use: "humidity",
|
||||||
@ -12,8 +12,8 @@ var humidityCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute a
|
// Execute a
|
||||||
func InitCmd(cmd *cobra.Command, cnf string) {
|
func InitCmd(cmd *cobra.Command, cnfPath string) {
|
||||||
configDir = cnf
|
configPath = cnfPath
|
||||||
|
|
||||||
cmd.AddCommand(humidityCmd)
|
cmd.AddCommand(humidityCmd)
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ var listTemperatureCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
// read configuration
|
// read configuration
|
||||||
cnf, err := config.Read(cnfPath)
|
cnf, err := config.Read(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ var readTemperatureCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
// read configuration
|
// read configuration
|
||||||
cnf, err := config.Read(cnfPath)
|
cnf, err := config.Read(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cnfPath string
|
var configPath string
|
||||||
|
|
||||||
var temperatureCmd = &cobra.Command{
|
var temperatureCmd = &cobra.Command{
|
||||||
Use: "temperature",
|
Use: "temperature",
|
||||||
@ -15,8 +15,8 @@ var temperatureCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute a
|
// Execute a
|
||||||
func InitCmd(cmd *cobra.Command, configPath string) {
|
func InitCmd(cmd *cobra.Command, cnfPath string) {
|
||||||
cnfPath = configPath
|
configPath = cnfPath
|
||||||
cmd.AddCommand(temperatureCmd)
|
cmd.AddCommand(temperatureCmd)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user