| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- package main
- import (
- "fmt"
- "github.com/spf13/cobra"
- )
- func NewEnableCmd() *cobra.Command {
- return &cobra.Command{
- Use: "enable",
- Short: "Enable RGB lighting",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, args []string) error {
- proto, target, channels, err := openTarget()
- if err != nil {
- return err
- }
- defer proto.Close()
- catalog, _, err := resolveCatalog(target)
- if err != nil {
- return err
- }
- for _, ch := range channels {
- if _, ok := catalog.DefaultEffect(ch); !ok {
- return fmt.Errorf("this keyboard has no effect names, so `enable` cannot choose an effect: " +
- "run `keyboard fetch` for its VIA definition, or set one with `effect <index>`")
- }
- }
- if err := enableLightingOnChannels(proto, channels, catalog); err != nil {
- return fmt.Errorf("enable RGB: %w", err)
- }
- fmt.Fprintln(cmd.OutOrStdout(), "RGB enabled")
- return nil
- },
- }
- }
|