package rgbled import ( "log" "github.com/go-flucky/flucky/pkg/config" "github.com/go-flucky/flucky/pkg/rgbled" "github.com/spf13/cobra" ) var offRgbLedCmd = &cobra.Command{ Use: "off", Short: "Turn a RGB-LED color off", Example: `flucky rgb-led off flucky rgb-led off my-led`, Run: func(cmd *cobra.Command, args []string) { // read configuration cnf, err := config.Read(configFile) if err != nil { log.Fatalln(err) } rgbLEDs := make([]rgbled.RGBLED, 0) if len(args) != 0 { rgbLEDs = cnf.GetRGBLEDsByName(args) } else { rgbLEDs = cnf.GetRGBLEDs(config.ENABLED) } err = rgbled.Off(rgbLEDs) if err != nil { log.Fatalln(err) } }, } func init() { rgbLedCmd.AddCommand(offRgbLedCmd) }