| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package main
- import (
- "fmt"
- "github.com/spf13/cobra"
- )
- func NewSpeedCmd() *cobra.Command {
- return withZoneArgs(&cobra.Command{
- Use: "speed <zone> <val>",
- Short: "Set effect speed on a zone",
- Long: writesLighting("Set the effect speed (0-255) and read it back, so a value the keyboard\n" +
- "rescales is reported instead of silently applied."),
- RunE: func(cmd *cobra.Command, args []string) error {
- val, err := ParseUint8(args[1])
- if err != nil {
- return err
- }
- proto, target, channels, err := openTarget(args[0])
- 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
- },
- }, 2, 2, "a zone and a speed value")
- }
|