package sensor import ( "log" "github.com/go-flucky/flucky/pkg/config" "github.com/spf13/cobra" ) var enableSensorCmd = &cobra.Command{ Use: "enable", Short: "Enable Sensor", Example: "flucky sensor enable outdoor", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { // read configuration cnf, err := config.Read(configFile) if err != nil { log.Fatalln(err) } // disable sensor entry to list err = cnf.EnableSensor(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(enableSensorCmd) }