PKGBUILD/cmd/sensor/remove.go

40 lines
710 B
Go

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