enable.go 671 B

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