Browse Source

add lucy color command for conversions.

asmodeus
Gisle Aune 3 years ago
parent
commit
2a750ae1f7
  1. 4
      cmd/lucy/help.go
  2. 24
      cmd/lucy/main.go

4
cmd/lucy/help.go

@ -36,6 +36,10 @@ EVENT HANDLER FACTORY COMMANDS
factory run <file.yaml> factory run <file.yaml>
MISC COMMANDS
color <color>
File example (use '---' to delimit multiple configs in one file): File example (use '---' to delimit multiple configs in one file):
mode: SceneDimmer mode: SceneDimmer
target: tag:Soverom target: tag:Soverom

24
cmd/lucy/main.go

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"git.aiterp.net/lucifer/new-server/app/client" "git.aiterp.net/lucifer/new-server/app/client"
"git.aiterp.net/lucifer/new-server/internal/color"
"git.aiterp.net/lucifer/new-server/models" "git.aiterp.net/lucifer/new-server/models"
"log" "log"
"os" "os"
@ -92,6 +93,29 @@ func main() {
WriteDeviceInfoTable(os.Stdout, devices) WriteDeviceInfoTable(os.Stdout, devices)
} }
case "color":
{
col, err := color.Parse(cmd.Params.Get(0).StringOr("hs:0,0"))
if err != nil {
log.Fatalln(err)
}
if col.IsKelvin() {
fmt.Println(col.String())
}
if hs, ok := col.ToHS(); ok {
fmt.Println(hs.String())
}
if hsk, ok := col.ToHSK(); ok {
fmt.Println(hsk.String())
}
if xy, ok := col.ToXY(); ok {
fmt.Println(xy.String())
}
if rgb, ok := col.ToRGB(); ok {
fmt.Println(rgb.String())
}
}
case "factory": case "factory":
factoryCmd(ctx, c) factoryCmd(ctx, c)

Loading…
Cancel
Save