Feat: reboot bridge + Fix: cli panic

This commit is contained in:
kayos@tcp.direct 2022-12-27 03:19:10 -08:00
parent 74d9ac7346
commit 8c3051b11c
Signed by: kayos
GPG Key ID: 4B841471B4BEE979
4 changed files with 12 additions and 1 deletions

View File

@ -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
}

View File

@ -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() {

View File

@ -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")

View File

@ -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