Skip to content

Commit

Permalink
Update logic for flags
Browse files Browse the repository at this point in the history
  • Loading branch information
squarejaw committed Jan 25, 2022
1 parent dda705a commit 4503073
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cmd/on.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down

0 comments on commit 4503073

Please sign in to comment.