go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/experiments/huectl/pkg/command/list_groups.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 "os" 12 13 "github.com/urfave/cli/v2" 14 ) 15 16 // ListGroups returns a command. 17 func ListGroups() *cli.Command { 18 return &cli.Command{ 19 Name: "list-groups", 20 Usage: "List groups associated with a given bridge.", 21 Flags: append(DefaultFlags, OutputFlags...), 22 Action: func(c *cli.Context) error { 23 bridge, err := initHelper(c) 24 if err != nil { 25 return err 26 } 27 28 lights, err := bridge.GetGroups(c.Context) 29 if err != nil { 30 return err 31 } 32 output(c, os.Stdout, lights) 33 return nil 34 }, 35 } 36 }