Skip to content

Commit

Permalink
Allow restarting core in safe mode (#474)
Browse files Browse the repository at this point in the history
* Allow restarting core in safe mode

* Use helper post method
  • Loading branch information
mdegat01 authored May 6, 2024
1 parent 722a8e6 commit c97c1a5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/core_restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ Restart the Home Assistant Core instance running on your system`,
section := "core"
command := "restart"

options := make(map[string]interface{})

safeMode, err := cmd.Flags().GetBool("safe-mode")
if err == nil && safeMode {
options["safe_mode"] = safeMode
}

ProgressSpinner.Start()
resp, err := helper.GenericJSONPostTimeout(section, command, nil, helper.ContainerOperationTimeout)
resp, err := helper.GenericJSONPostTimeout(section, command, options, helper.ContainerOperationTimeout)
ProgressSpinner.Stop()

if err != nil {
fmt.Println(err)
ExitWithError = true
Expand All @@ -37,5 +45,9 @@ Restart the Home Assistant Core instance running on your system`,
}

func init() {
coreRestartCmd.Flags().BoolP("safe-mode", "s", false, "Restart Home Assistant in safe mode")
coreRestartCmd.Flags().Lookup("safe-mode").NoOptDefVal = "true"
coreRestartCmd.RegisterFlagCompletionFunc("safe-mode", boolCompletions)

coreCmd.AddCommand(coreRestartCmd)
}

0 comments on commit c97c1a5

Please sign in to comment.