disable.go 700 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/spf13/cobra"
  6. )
  7. func NewDisableCmd() *cobra.Command {
  8. return &cobra.Command{
  9. Use: "disable",
  10. Short: "Disable RGB lighting",
  11. Args: cobra.NoArgs,
  12. Run: func(cmd *cobra.Command, args []string) {
  13. zones, err := selectedZones()
  14. if err != nil {
  15. fmt.Fprintf(os.Stderr, "Error: %v\n", err)
  16. os.Exit(1)
  17. }
  18. proto, err := OpenDevice()
  19. if err != nil {
  20. fmt.Fprintf(os.Stderr, "Error: %v\n", err)
  21. os.Exit(1)
  22. }
  23. defer proto.Close()
  24. if err := disableLightingOnZones(proto, zones); err != nil {
  25. fmt.Fprintf(os.Stderr, "Error disabling RGB: %v\n", err)
  26. os.Exit(1)
  27. }
  28. fmt.Println("RGB disabled")
  29. },
  30. }
  31. }