Compare commits
2 Commits
a357f2a924
...
4b311bcd5d
Author | SHA1 | Date | |
---|---|---|---|
kayos@tcp.direct | 4b311bcd5d | ||
kayos@tcp.direct | 3bb07c5854 |
|
@ -34,7 +34,7 @@ func executor(cmd string) {
|
|||
var status = 0
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Error().Caller().Msgf("PANIC: %s", r)
|
||||
log.Error().Caller(3).Msgf("PANIC: %s", r)
|
||||
}
|
||||
if _, ok := noHist[cmd]; !ok && status == 0 {
|
||||
history = append(history, cmd)
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -284,7 +285,7 @@ func cmdDump(br *ziggy.Bridge, args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
name = target.(*huego.Group).Name
|
||||
name = target.(*ziggy.HueGroup).Name
|
||||
case "schedule":
|
||||
return errors.New("not implemented")
|
||||
case "rule":
|
||||
|
@ -321,12 +322,23 @@ func cmdDump(br *ziggy.Bridge, args []string) error {
|
|||
return errors.New("invalid target type")
|
||||
}
|
||||
|
||||
if js, err := json.Marshal(target); err != nil {
|
||||
js, err := json.Marshal(target)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
return os.WriteFile(name+".json", js, 0o666)
|
||||
}
|
||||
|
||||
name = name + ".json"
|
||||
if err := os.WriteFile(name, js, 0o666); err != nil {
|
||||
return err
|
||||
}
|
||||
// get current working directory
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
// we can't get the current working directory, but the file was written successfully (in theory).
|
||||
// so just return nil without printing the path
|
||||
return nil
|
||||
}
|
||||
log.Info().Msgf("dumped to: %s", filepath.Join(wd, name))
|
||||
return nil
|
||||
}
|
||||
|
||||
// cmdLoad imports a target JSON object and attempts to apply it to an existing object
|
||||
|
@ -373,7 +385,7 @@ func cmdLoad(br *ziggy.Bridge, args []string) error {
|
|||
if err := json.Unmarshal(js, &g); err != nil {
|
||||
return err
|
||||
}
|
||||
if resp, err := br.UpdateGroup(target.(*huego.Group).ID, *g); err != nil {
|
||||
if resp, err := br.UpdateGroup(target.(*ziggy.HueGroup).ID, *g); err != nil {
|
||||
return err
|
||||
} else {
|
||||
log.Info().Msgf("%v", resp)
|
||||
|
|
Loading…
Reference in New Issue