From 4503073ad77024a96f1639106595a2cf1b0ced7b Mon Sep 17 00:00:00 2001 From: Bryan Bess <1250248+squarejaw@users.noreply.github.com> Date: Mon, 24 Jan 2022 20:01:23 -0600 Subject: [PATCH] Update logic for flags --- cmd/on.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/on.go b/cmd/on.go index 2ef8471..1548765 100644 --- a/cmd/on.go +++ b/cmd/on.go @@ -32,22 +32,22 @@ var onCmd = &cobra.Command{ Dimming: &dimming, }, } - if temp >= 1000 { + if cmd.Flag("temp").Changed { b.Params.Temp = &temp } - if red > 0 { + if cmd.Flag("red").Changed { b.Params.Red = &red } - if green > 0 { + if cmd.Flag("green").Changed { b.Params.Green = &green } - if blue > 0 { + if cmd.Flag("blue").Changed { b.Params.Blue = &blue } - if coldWhite > 0 { + if cmd.Flag("cold-white").Changed { b.Params.ColdWhite = &coldWhite } - if warmWhite > 0 { + if cmd.Flag("warm-white").Changed { b.Params.WarmWhite = &warmWhite } result, err := b.SetState(timeout) @@ -58,7 +58,8 @@ var onCmd = &cobra.Command{ func init() { rootCmd.AddCommand(onCmd) - onCmd.Flags().IntVarP(&temp, "kelvin", "k", 0, "temperature in Kelvin") + onCmd.Flags().SortFlags = false + onCmd.Flags().IntVarP(&temp, "temp", "k", 0, "temperature in Kelvin") onCmd.Flags().IntVarP(&dimming, "dimming", "d", 50, "dimming") onCmd.Flags().IntVarP(&red, "red", "r", 0, "red") onCmd.Flags().IntVarP(&green, "green", "g", 0, "green")