Browse Source

add scene list subcommand.

feature-colorvalue2
Gisle Aune 3 years ago
parent
commit
7471102413
  1. 10
      cmd/lucy/scenecmd.go
  2. 18
      cmd/lucy/tables.go

10
cmd/lucy/scenecmd.go

@ -19,6 +19,16 @@ func sceneCmd(
cmd := parseCommand(os.Args[2:])
switch cmd.Name {
case "list":
{
scenes, err := c.GetScenes(ctx)
if err != nil {
log.Fatalln("Failed to load scenes:", err)
}
WriteSceneTable(os.Stdout, scenes)
}
case "create", "update":
{
fileName := cmd.Params.Get(0).String()

18
cmd/lucy/tables.go

@ -94,6 +94,24 @@ func WriteDeviceInfoTable(w io.Writer, devices []models.Device) {
table.Render()
}
func WriteSceneTable(w io.Writer, scenes []models.Scene) {
table := tablewriter.NewWriter(w)
table.SetHeader([]string{"ID", "NAME", "ROLES", "INTERVAL"})
table.SetReflowDuringAutoWrap(false)
for _, v := range scenes {
table.Append([]string{
fmt.Sprint(v.ID),
v.Name,
fmt.Sprint(len(v.Roles)),
fmt.Sprint(v.IntervalMS),
})
}
table.Render()
}
func WriteHandlerInfoTable(w io.Writer, handlers []models.EventHandler) {
table := tablewriter.NewWriter(w)
table.SetHeader([]string{"ID", "EVENT NAME", "PRIORITY", "CONDITIONS", "TARGET", "ACTION"})

Loading…
Cancel
Save