-
-
Notifications
You must be signed in to change notification settings - Fork 117
Add --feature-flag option to supervisor options command #649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,9 @@ | ||||||
| package cmd | ||||||
|
|
||||||
| import ( | ||||||
| "fmt" | ||||||
| "log/slog" | ||||||
| "strconv" | ||||||
| "strings" | ||||||
|
|
||||||
| helper "github.com/home-assistant/cli/client" | ||||||
|
|
@@ -16,7 +18,8 @@ var supervisorOptionsCmd = &cobra.Command{ | |||||
| This command allows you to set configuration options for on the Home Assistant | ||||||
| Supervisor running on your Home Assistant system.`, | ||||||
| Example: ` | ||||||
| ha supervisor options --channel beta`, | ||||||
| ha supervisor options --channel beta | ||||||
| ha supervisor options --feature-flag supervisor_v2_api=true`, | ||||||
| ValidArgsFunction: cobra.NoFileCompletions, | ||||||
| Args: cobra.NoArgs, | ||||||
| Run: func(cmd *cobra.Command, args []string) { | ||||||
|
|
@@ -52,6 +55,30 @@ Supervisor running on your Home Assistant system.`, | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| featureFlags, err := cmd.Flags().GetStringArray("feature-flag") | ||||||
| if err == nil && len(featureFlags) > 0 { | ||||||
| flagMap := make(map[string]bool) | ||||||
| for _, entry := range featureFlags { | ||||||
| parts := strings.SplitN(entry, "=", 2) | ||||||
| var name string | ||||||
| var val bool | ||||||
| if len(parts) == 1 { | ||||||
| name = parts[0] | ||||||
| val = true | ||||||
| } else { | ||||||
| name = parts[0] | ||||||
| val, err = strconv.ParseBool(parts[1]) | ||||||
| if err != nil { | ||||||
| helper.PrintError(fmt.Errorf("invalid value for feature flag %q: %q, expected true or false", name, parts[1])) | ||||||
| ExitWithError = true | ||||||
| return | ||||||
| } | ||||||
| } | ||||||
| flagMap[name] = val | ||||||
| } | ||||||
| options["feature_flags"] = flagMap | ||||||
| } | ||||||
|
|
||||||
| resp, err := helper.GenericJSONPost(section, command, options) | ||||||
| if err != nil { | ||||||
| helper.PrintError(err) | ||||||
|
|
@@ -72,6 +99,7 @@ func init() { | |||||
| supervisorOptionsCmd.Flags().BoolP("debug-block", "", false, "Enable debug mode with blocking startup") | ||||||
| supervisorOptionsCmd.Flags().BoolP("diagnostics", "", false, "Enable diagnostics mode") | ||||||
| supervisorOptionsCmd.Flags().BoolP("auto-update", "", true, "Enable/disable supervisor auto update") | ||||||
| supervisorOptionsCmd.Flags().StringArrayP("feature-flag", "", []string{}, "Set a development feature flag (name=true|false). Use multiple times for multiple flags.") | ||||||
|
||||||
| supervisorOptionsCmd.Flags().StringArrayP("feature-flag", "", []string{}, "Set a development feature flag (name=true|false). Use multiple times for multiple flags.") | |
| supervisorOptionsCmd.Flags().StringArrayP("feature-flag", "", []string{}, "Set a development feature flag (name[=true|false]). Bare name defaults to true. Use multiple times for multiple flags.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems kinda obvious to me, or can be explored if needs to be. No extra documentation needed.
Copilot
AI
Apr 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
featureFlagCompletions iterates over a Go map, so completion ordering will be nondeterministic between runs/shell invocations. Consider collecting the flag names, sorting them, and then appending suggestions in a stable order to avoid a noisy/unstable completion UX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't do this in other places right now, so I don't think we need to start it with this PR.
Uh oh!
There was an error while loading. Please reload this page.