PKGBUILD/cmd/sensor/disable.go

41 lines
705 B
Go
Raw Normal View History

2018-11-28 17:07:20 +00:00
package sensor
2019-02-24 21:46:36 +00:00
import (
"log"
2019-06-15 13:58:41 +00:00
"github.com/go-flucky/flucky/pkg/config"
2019-02-24 21:46:36 +00:00
"github.com/spf13/cobra"
)
var disableSensorCmd = &cobra.Command{
Use: "disable",
Short: "Disable Sensor",
Args: cobra.ExactArgs(1),
Example: "flucky sensor disable outdoor",
Run: func(cmd *cobra.Command, args []string) {
// read configuration
cnf, err := config.Read(*configFile)
2019-02-24 21:46:36 +00:00
if err != nil {
log.Fatalln(err)
}
// disable sensor entry to list
err = cnf.DisableSensor(args[0])
2019-02-24 21:46:36 +00:00
if err != nil {
log.Fatalln(err)
}
// save new configuration
err = config.Write(cnf, *configFile)
2019-02-24 21:46:36 +00:00
if err != nil {
log.Fatalln(err)
}
},
}
func init() {
sensorCmd.AddCommand(disableSensorCmd)
}