| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package main
- import (
- "fmt"
- "github.com/spf13/cobra"
- )
- func NewEnableCmd() *cobra.Command {
- return withZoneArgs(&cobra.Command{
- Use: "enable <zone>",
- Short: "Enable RGB lighting on a zone",
- Long: writesLighting("Turn the lighting on on the named channels, at the first effect the\n" +
- "keyboard's own definition names for each of them and a brightness of 160."),
- RunE: func(cmd *cobra.Command, args []string) error {
- proto, target, channels, err := openTarget(args[0])
- 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 <zone> <index>`")
- }
- }
- if err := enableLightingOnChannels(proto, channels, catalog); err != nil {
- return fmt.Errorf("enable RGB: %w", err)
- }
- fmt.Fprintln(cmd.OutOrStdout(), "RGB enabled")
- return nil
- },
- }, 1, 1, "a zone")
- }
|