go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/experiments/huectl/pkg/command/set_group_off.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package command
     9  
    10  import (
    11  	"github.com/urfave/cli/v2"
    12  )
    13  
    14  // SetGroupOff returns a command.
    15  func SetGroupOff() *cli.Command {
    16  	return &cli.Command{
    17  		Name:  "set-group-off",
    18  		Usage: "Set all of a given group's lights off.",
    19  		Flags: append(DefaultFlags, GroupFlags...),
    20  		Action: func(c *cli.Context) error {
    21  			group, _, err := groupHelper(c)
    22  			if err != nil {
    23  				return err
    24  			}
    25  
    26  			if err = group.Off(c.Context); err != nil {
    27  				return err
    28  			}
    29  			printf(c, "group %q turned off\n", group.Name)
    30  			return nil
    31  		},
    32  	}
    33  }