package main import ( "fmt" "github.com/spf13/cobra" ) func NewSpeedCmd() *cobra.Command { return &cobra.Command{ Use: "speed ", Short: "Set effect speed", Long: "Set the effect speed (0-255) and read it back, so a value the keyboard\n" + "rescales is reported instead of silently applied.", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { val, err := ParseUint8(args[0]) if err != nil { return err } proto, target, channels, err := openTarget() if err != nil { return err } defer proto.Close() results, err := setSpeedVerified(proto, channels, target.Display, val) if err != nil { return fmt.Errorf("set speed: %w", err) } if anyMismatch(results) { fmt.Fprintln(cmd.OutOrStdout(), formatResults("Speed", results)) return nil } fmt.Fprintf(cmd.OutOrStdout(), "Speed set to %d\n", val) return nil }, } }