PKGBUILD/cmd/sensor/rm.go

40 lines
696 B
Go

package sensor
import (
"log"
"github.com/spf13/cobra"
"github.com/volker-raschek/flucky/pkg/config"
)
var rmSensorCmd = &cobra.Command{
Use: "rm",
Short: "Remove Sensor",
Example: "flucky sensor rm outdoor",
Aliases: []string{"remove"},
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
// read configuration
fc, err := config.Read(cfg)
if err != nil {
log.Fatalln(err)
}
// // add remote entry to list
err = fc.RemoveSensor(args[0])
if err != nil {
log.Fatalln(err)
}
// save new configuration
err = config.Write(fc, cfg)
if err != nil {
log.Fatalln(err)
}
},
}
func init() {
sensorCmd.AddCommand(rmSensorCmd)
}