From 8c3051b11cf34e727e857ad5b1ff8106e7b54911 Mon Sep 17 00:00:00 2001 From: "kayos@tcp.direct" Date: Tue, 27 Dec 2022 03:19:10 -0800 Subject: [PATCH] Feat: reboot bridge + Fix: cli panic --- internal/cli/commands.go | 9 +++++++++ internal/cli/completer.go | 1 + vendor/git.tcp.direct/Mirrors/go-prompt/completion.go | 2 +- vendor/github.com/amimof/huego/config.go | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/cli/commands.go b/internal/cli/commands.go index 90c90ae..1f9ae23 100644 --- a/internal/cli/commands.go +++ b/internal/cli/commands.go @@ -411,3 +411,12 @@ func cmdAdopt(br *ziggy.Bridge, args []string) error { } return nil } + +func cmdReboot(br *ziggy.Bridge, args []string) error { + resp, err := br.UpdateConfig(&huego.Config{Reboot: true}) + if err != nil { + return err + } + log.Info().Msgf("%v", resp) + return nil +} diff --git a/internal/cli/completer.go b/internal/cli/completer.go index 0cd5f90..924733f 100644 --- a/internal/cli/completer.go +++ b/internal/cli/completer.go @@ -86,6 +86,7 @@ func init() { "fwup", "upgrade", "fwupdate") Commands["info"] = newZiggsCommand(cmdInfo, "show information about a bridge", 0, "uname") initCompletion() + Commands["reboot"] = newZiggsCommand(cmdReboot, "reboot bridge", 0) } func initCompletion() { diff --git a/vendor/git.tcp.direct/Mirrors/go-prompt/completion.go b/vendor/git.tcp.direct/Mirrors/go-prompt/completion.go index 7ba446c..f0e4ada 100644 --- a/vendor/git.tcp.direct/Mirrors/go-prompt/completion.go +++ b/vendor/git.tcp.direct/Mirrors/go-prompt/completion.go @@ -41,7 +41,7 @@ type CompletionManager struct { // GetSelectedSuggestion returns the selected item. func (c *CompletionManager) GetSelectedSuggestion() (s Suggest, ok bool) { - if c.selected == -1 { + if c.selected == -1 || len(c.tmp) == 0 { return Suggest{}, false } else if c.selected < -1 { debug.Assert(false, "must not reach here") diff --git a/vendor/github.com/amimof/huego/config.go b/vendor/github.com/amimof/huego/config.go index 9283119..5cdeea3 100644 --- a/vendor/github.com/amimof/huego/config.go +++ b/vendor/github.com/amimof/huego/config.go @@ -30,6 +30,7 @@ type Config struct { DatastoreVersion string `json:"datastoreversion,omitempty"` StarterKitID string `json:"starterkitid,omitempty"` InternetService InternetService `json:"internetservices,omitempty"` + Reboot bool `json:"reboot,omitempty"` } // SwUpdate contains information related to software updates. Deprecated in 1.20