package main import ( "fmt" "github.com/spf13/cobra" ) func NewModeCmd() *cobra.Command { return &cobra.Command{ Use: "mode ", Short: "Set effect mode by index", Long: "Set the effect mode by numeric index (0-255). The index is the\n" + "channel's own: 5 is light on rgblight and rainbow_beacon on rgb_matrix.\n" + "Use `effect ` where a catalog exists, which is unambiguous.", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { val, err := ParseUint8(args[0]) if err != nil { return err } proto, _, channels, err := openTarget() if err != nil { return err } defer proto.Close() if err := setModeOnChannels(proto, channels, val); err != nil { return fmt.Errorf("set mode: %w", err) } fmt.Fprintf(cmd.OutOrStdout(), "Mode set to index %d\n", val) return nil }, } }