fix: temperature, sensor

changes:
- sensor temperature add
- sensor temperature list
- sensor temperature rm
- temperature get
- temperature log
- temperature push
This commit is contained in:
2018-11-20 22:55:06 +01:00
parent dd7ea3156e
commit 6d9368e86c
25 changed files with 850 additions and 48 deletions

View File

@ -1,4 +1,4 @@
package remote
package temperature
import (
"log"
@ -8,13 +8,15 @@ import (
"github.com/spf13/cobra"
)
var push bool
var getTemperatureCmd = &cobra.Command{
Use: "get",
Short: "get temperature from sensor",
// Args: cobra.ExactArgs(2),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if err := temperature.Get(os.Stdout); err != nil {
if err := temperature.Get(os.Stdout, args[0], configDir); err != nil {
log.Fatal(err)
}
},

27
cmd/temperature/logs.go Normal file
View File

@ -0,0 +1,27 @@
package temperature
import (
"log"
"os"
"git.cryptic.systems/fh-trier/go-flucky/pkg/temperature"
"github.com/spf13/cobra"
)
//var seconds int32
var logTemperatureCmd = &cobra.Command{
Use: "logs",
Short: "logs print all temperatures from all sensors",
Run: func(cmd *cobra.Command, args []string) {
if err := temperature.Logs(os.Stdout, configDir); err != nil {
log.Fatal(err)
}
},
}
func init() {
temperatureCmd.AddCommand(logTemperatureCmd)
//logTemperatureCmd.Flags().Int32VarP(&seconds, "seconds", "s", 1, "Interval to print new temperatures from sensors")
}

24
cmd/temperature/push.go Normal file
View File

@ -0,0 +1,24 @@
package temperature
import (
"log"
"git.cryptic.systems/fh-trier/go-flucky/pkg/temperature"
"github.com/spf13/cobra"
)
var pushTemperatureCmd = &cobra.Command{
Use: "push",
Short: "push temperature from sensor to remote servers",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if err := temperature.Push(args[0], configDir); err != nil {
log.Fatal(err)
}
},
}
func init() {
temperatureCmd.AddCommand(pushTemperatureCmd)
}

View File

@ -1,16 +1,19 @@
package remote
package temperature
import (
"github.com/spf13/cobra"
)
var configDir string
var temperatureCmd = &cobra.Command{
Use: "temperature",
Short: "Read temperature from sensor",
}
// Execute a
func Init(cmd *cobra.Command) {
func InitCmd(cmd *cobra.Command, cnf string) {
configDir = cnf
cmd.AddCommand(temperatureCmd)