Consolidate subcommand registration
This commit is contained in:
@ -1,53 +1,12 @@
|
||||
package lumecmd
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
lifx "git.kill0.net/chill9/lume"
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterCommand("set-color", Command{
|
||||
Func: SetColorCmd,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("set-color", flag.ExitOnError)
|
||||
|
||||
selector := fs.String("selector", "all", "the selector")
|
||||
fs.StringVar(selector, "s", "all", "the selector")
|
||||
|
||||
power := fs.String("power", defaultPower, "power state")
|
||||
fs.StringVar(power, "p", defaultPower, "power state")
|
||||
|
||||
hue := fs.String("hue", defaultHue, "hue level")
|
||||
fs.StringVar(hue, "H", defaultHue, "hue level")
|
||||
|
||||
saturation := fs.String("saturation", defaultSaturation, "saturation level")
|
||||
fs.StringVar(saturation, "S", defaultSaturation, "saturation level")
|
||||
|
||||
rgb := fs.String("rgb", defaultRGB, "RGB value")
|
||||
fs.StringVar(rgb, "r", defaultRGB, "RGB value")
|
||||
|
||||
name := fs.String("name", defaultName, "named color")
|
||||
fs.StringVar(name, "n", defaultName, "named color")
|
||||
|
||||
brightness := fs.String("brightness", defaultBrightness, "brightness state")
|
||||
fs.StringVar(brightness, "b", defaultBrightness, "brightness state")
|
||||
|
||||
duration := fs.Float64("duration", defaultDuration, "duration state")
|
||||
fs.Float64Var(duration, "d", defaultDuration, "duration state")
|
||||
|
||||
fast := fs.Bool("fast", defaultFast, "fast state")
|
||||
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
||||
|
||||
return fs
|
||||
}(),
|
||||
Use: "[--selector <selector>] [--power (on|off)] [--hue <hue>] [--saturation <saturation>] [--rgb <rbg>] [--name <color>] [--brightness <brightness>] [--duration <sec>] [--fast]",
|
||||
Short: "Set the color",
|
||||
})
|
||||
}
|
||||
|
||||
func SetColorCmd(args CmdArgs) (int, error) {
|
||||
c := args.Client
|
||||
state := lifx.State{}
|
||||
|
Reference in New Issue
Block a user