package main import ( "fmt" "github.com/spf13/cobra" intrgb "netdome.biz/paul/qmk-rgb/internal/rgb" ) func NewEnableCmd() *cobra.Command { return &cobra.Command{ Use: "enable", Short: "Enable RGB lighting", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { proto, target, channels, err := openTarget() if err != nil { return err } defer proto.Close() catalog, _ := intrgb.CatalogFor(target.Device.VendorID, target.Device.ProductID) for _, ch := range channels { if _, ok := catalog.DefaultEffect(ch); !ok { return fmt.Errorf("this keyboard has no effect catalog, so `enable` cannot choose an effect; set one with `mode `") } } if err := enableLightingOnChannels(proto, channels, catalog); err != nil { return fmt.Errorf("enable RGB: %w", err) } fmt.Fprintln(cmd.OutOrStdout(), "RGB enabled") return nil }, } }