2020-03-25 00:12:35 +00:00
|
|
|
package lumecmd
|
|
|
|
|
|
|
|
import (
|
2020-03-27 00:05:50 +00:00
|
|
|
"flag"
|
2020-03-25 00:12:35 +00:00
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-03-27 01:51:26 +00:00
|
|
|
idWidth, locationWidth, groupWidth, labelWidth, lastSeenWidth, powerWidth int
|
2020-03-25 00:12:35 +00:00
|
|
|
)
|
|
|
|
|
2020-03-27 00:05:50 +00:00
|
|
|
func init() {
|
|
|
|
fs := flag.NewFlagSet("toggle", flag.ExitOnError)
|
2020-03-27 03:00:16 +00:00
|
|
|
selector := fs.String("selector", "all", "Set the selector")
|
|
|
|
fs.StringVar(selector, "s", "all", "Set the selector")
|
2020-03-27 00:05:50 +00:00
|
|
|
|
|
|
|
RegisterCommand("ls", Command{
|
|
|
|
Func: LsCmd,
|
|
|
|
Flags: fs,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-03-25 00:12:35 +00:00
|
|
|
func LsCmd(args CmdArgs) int {
|
|
|
|
c := args.Client
|
2020-03-27 00:05:50 +00:00
|
|
|
selector := args.Flags.String("selector")
|
|
|
|
lights, err := c.ListLights(selector)
|
2020-03-25 00:12:35 +00:00
|
|
|
if err != nil {
|
2020-03-28 00:31:12 +00:00
|
|
|
fmt.Printf("fatal: %s\n", err)
|
2020-03-25 00:12:35 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
PrintLights(lights)
|
|
|
|
return 0
|
|
|
|
}
|