fix: breaking changes
changes: - remove remote operations - add function to write measured values into a channel - add get humidity sensors from config - add get temperature sensors from config - remove FileLogger - exclude some functions from pkf into internal
This commit is contained in:
28
cmd/temperature/list.go
Normal file
28
cmd/temperature/list.go
Normal file
@ -0,0 +1,28 @@
|
||||
package temperature
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var listTemperatureCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "print temperatures",
|
||||
Example: fmt.Sprintf("flucky temperature logs"),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
// read configuration
|
||||
// fc, err := config.Read(cnfPath)
|
||||
// if err != nil {
|
||||
// list.Fatalln(err)
|
||||
// }
|
||||
|
||||
//cli.PrintTemperatures(temperatures, fc, os.Stdout)
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
temperatureCmd.AddCommand(listTemperatureCmd)
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package temperature
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/volker-raschek/flucky/pkg/cli"
|
||||
"github.com/volker-raschek/flucky/pkg/config"
|
||||
)
|
||||
|
||||
var logTemperatureCmd = &cobra.Command{
|
||||
Use: "log",
|
||||
Short: "print temperature logs",
|
||||
Example: fmt.Sprintf("flucky temperature logs"),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
// read configuration
|
||||
fc, err := config.Read(cfg)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
temperatures, err := fc.FileLogger.GetTemperatures(nil, nil, args)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
cli.PrintTemperatures(temperatures, fc, os.Stdout)
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
temperatureCmd.AddCommand(logTemperatureCmd)
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package temperature
|
||||
|
||||
// import (
|
||||
// "log"
|
||||
|
||||
// "github.com/spf13/cobra"
|
||||
// )
|
||||
|
||||
// var pushTemperatureCmd = &cobra.Command{
|
||||
// Use: "push",
|
||||
// Short: "push temperature from sensor to remote servers",
|
||||
// Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
// if err := temperature.Push(configDir); err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// },
|
||||
// }
|
||||
|
||||
// func init() {
|
||||
// temperatureCmd.AddCommand(pushTemperatureCmd)
|
||||
// }
|
@ -20,16 +20,13 @@ var readTemperatureCmd = &cobra.Command{
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
// read configuration
|
||||
fc, err := config.Read(cfg)
|
||||
cnf, err := config.Read(cnfPath)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
// fetch all temperature sensors
|
||||
temperatureSensors, err := fc.GetTemperatureSensors(args)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
temperatureSensors := cnf.GetTemperatureSensors()
|
||||
|
||||
// read temperature from sensors
|
||||
temperatures, err := sensor.ReadTemperatures(temperatureSensors)
|
||||
@ -38,14 +35,7 @@ var readTemperatureCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
// print temperatures on stdout
|
||||
cli.PrintTemperatures(temperatures, fc, os.Stdout)
|
||||
|
||||
if logs {
|
||||
err = fc.FileLogger.LogTemperatures(temperatures)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
cli.PrintTemperatures(temperatures, cnf, os.Stdout)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var cfg string
|
||||
var cnfPath string
|
||||
|
||||
var temperatureCmd = &cobra.Command{
|
||||
Use: "temperature",
|
||||
@ -15,8 +15,8 @@ var temperatureCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
// Execute a
|
||||
func InitCmd(cmd *cobra.Command, config string) {
|
||||
cfg = config
|
||||
func InitCmd(cmd *cobra.Command, configPath string) {
|
||||
cnfPath = configPath
|
||||
|
||||
cmd.AddCommand(temperatureCmd)
|
||||
|
||||
|
Reference in New Issue
Block a user