refactor command line code

This commit is contained in:
2020-03-26 19:05:50 -05:00
parent 6afe13812a
commit 7ef6d66564
4 changed files with 134 additions and 112 deletions

View File

@ -1,6 +1,7 @@
package lumecmd
import (
"flag"
"fmt"
"time"
@ -16,9 +17,20 @@ var (
powerWidth int = 0
)
func init() {
fs := flag.NewFlagSet("toggle", flag.ExitOnError)
fs.String("selector", "all", "Set the selector")
RegisterCommand("ls", Command{
Func: LsCmd,
Flags: fs,
})
}
func LsCmd(args CmdArgs) int {
c := args.Client
lights, err := c.ListLights(args.Selector)
selector := args.Flags.String("selector")
lights, err := c.ListLights(selector)
if err != nil {
fmt.Println(err)
return 1