2019-06-16 11:00:50 +00:00
|
|
|
package rgbled
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/go-flucky/flucky/pkg/config"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var disableRgbLedCmd = &cobra.Command{
|
|
|
|
Use: "disable",
|
|
|
|
Short: "Disable a RGB-LED",
|
|
|
|
Args: cobra.ExactArgs(1),
|
|
|
|
Example: `flucky rgb-led disable <name/uuid>
|
|
|
|
flucky rgb-led disable my-led
|
|
|
|
flucky rgb-led disable 9f8abfc5-91f3-480c-a42d-b990b6f89e5d`,
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
|
|
// read configuration
|
2019-08-19 10:24:08 +00:00
|
|
|
cnf, err := config.Read(*configFile)
|
2019-06-16 11:00:50 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// disable sensor entry to list
|
|
|
|
err = cnf.DisableRGBLED(args[0])
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// save new configuration
|
2019-08-19 10:24:08 +00:00
|
|
|
err = config.Write(cnf, *configFile)
|
2019-06-16 11:00:50 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rgbLedCmd.AddCommand(disableRgbLedCmd)
|
|
|
|
}
|