PKGBUILD/cmd/sensor/add.go
Markus Pesch f8e829d3d2
fix: sync and fetch temperatures
changes:
- add sync command to synchronize device sensor information with remote
  servers
- fix fetch functions to get temperatures
2018-11-29 16:06:39 +01:00

31 lines
885 B
Go

package sensor
import (
"log"
"git.cryptic.systems/fh-trier/go-flucky/pkg/sensor"
"github.com/spf13/cobra"
)
var enabled bool
var sensorLocation, wireID, wirePath string
var addSensorCmd = &cobra.Command{
Use: "add",
Short: "Add Sensor",
Args: cobra.ExactArgs(3),
Run: func(cmd *cobra.Command, args []string) {
if err := sensor.Add(&args[0], &sensorLocation, &args[1], &wireID, &args[2], wirePath, configDir, &enabled); err != nil {
log.Fatal(err)
}
},
}
func init() {
sensorCmd.AddCommand(addSensorCmd)
addSensorCmd.Flags().BoolVarP(&enabled, "enabled", "e", true, "Enable Sensor")
addSensorCmd.Flags().StringVarP(&sensorLocation, "sensor-location", "l", "", "Sensor location")
addSensorCmd.Flags().StringVarP(&wireID, "wire-id", "i", "", "Wire-ID")
addSensorCmd.Flags().StringVarP(&wirePath, "wire-path", "w", "/sys/bus/w1/devices", "Wire device path")
}