Skip to content

Commit

Permalink
Add safe mode option to core rebuild (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 authored Jun 17, 2024
1 parent 56633c7 commit 8d8c11a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/core_rebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ Don't worry, this does not delete your config.`,
section := "core"
command := "rebuild"

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)
Expand All @@ -39,5 +46,9 @@ Don't worry, this does not delete your config.`,
}

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

coreCmd.AddCommand(coreRebuildCmd)
}

0 comments on commit 8d8c11a

Please sign in to comment.