go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/experiments/huectl/pkg/command/set_light_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 // SetLightOff returns a command. 15 func SetLightOff() *cli.Command { 16 return &cli.Command{ 17 Name: "set-light-off", 18 Usage: "Set a given light off.", 19 Flags: append( 20 DefaultFlags, 21 LightFlags..., 22 ), 23 Action: func(c *cli.Context) error { 24 light, _, err := lightHelper(c) 25 if err != nil { 26 return err 27 } 28 if err = light.Off(c.Context); err != nil { 29 return err 30 } 31 32 printf(c, "light %q turned off\n", light.Name) 33 return nil 34 }, 35 } 36 }