-
Notifications
You must be signed in to change notification settings - Fork 7
Added feature flag to the CLI config #456
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
Conversation
WalkthroughAdds a feature-flag subsystem for "prompts evaluations", initializes it during CLI startup, exposes helpers to query the flag, logs the flag state in the bundle command when enabled, and prints the flag status in the long version output. No other control flow or error handling changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant CLI as CLI (cobra)
participant FF as Feature Flags (viper)
participant Cmd as Command (bundle/version)
Note over CLI: binary startup
U->>CLI: invoke
CLI->>FF: SetupFeatureFlags(rootCmd)
Note over FF: register hidden flag (--enable-prompts-evals), no auto-bind
CLI->>Cmd: execute chosen command
alt bundle command
Cmd->>FF: IsPromptsEvalsEnabled()
FF-->>Cmd: bool
opt enabled
Cmd->>Cmd: log "Prompts evaluations feature is enabled"
end
Cmd->>Cmd: continue bundling
else version --long
Cmd->>FF: IsPromptsEvalsEnabled()
FF-->>Cmd: bool
opt enabled
Cmd->>U: print "Prompts Evals: Enabled"
end
Cmd->>U: print version details
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (7)
cmd/feature_flags.go (4)
15-21: BindPFlag/MarkHidden errors are ignored; handle them to avoid silent misconfigCobra/Viper return errors here; capture them so a bind/flag regression doesn’t silently disable the feature.
func SetupFeatureFlags(rootCmd *cobra.Command) { // Set default values viper.SetDefault("features.enable_prompts_evals", false) // Add command line flags - rootCmd.PersistentFlags().Bool("enable-prompts-evals", false, "Enable prompts evals") - rootCmd.PersistentFlags().MarkHidden("enable-prompts-evals") - viper.BindPFlag("features.enable_prompts_evals", rootCmd.PersistentFlags().Lookup("enable-prompts-evals")) + rootCmd.PersistentFlags().Bool("enable-prompts-evals", false, "Enable prompt evaluations") + if err := rootCmd.PersistentFlags().MarkHidden("enable-prompts-evals"); err != nil { + cobra.CheckErr(err) + } + if err := viper.BindPFlag("features.enable_prompts_evals", rootCmd.PersistentFlags().Lookup("enable-prompts-evals")); err != nil { + cobra.CheckErr(err) + } }Based on learnings.
30-33: Fix inaccurate docstringThe comment says “IsExperimentalEnabled” but the function is IsPromptsEvalsEnabled.
-// IsExperimentalEnabled checks if experimental features are enabled +// IsPromptsEvalsEnabled reports whether the "prompt evaluations" feature flag is enabled. func IsPromptsEvalsEnabled() bool { return IsFeatureEnabled(FeaturePromptsEvals) }
45-48: Future‑proof IsAnyFeatureEnabledRoute through GetEnabledFeatures so adding more flags doesn’t require touching this helper.
-func IsAnyFeatureEnabled() bool { - return IsPromptsEvalsEnabled() -} +func IsAnyFeatureEnabled() bool { + return len(GetEnabledFeatures()) > 0 +}
8-11: Consider constants for CLI flag and viper key to avoid string driftSmall ergonomics tweak: define flag/key constants so usage sites don’t diverge as features grow.
Example:
const ( viperKeyPrefix = "features." FlagPromptsEvals = "enable-prompts-evals" ViperKeyPromptsEvals = viperKeyPrefix + FeaturePromptsEvals )Then bind using ViperKeyPromptsEvals and FlagPromptsEvals.
cmd/version.go (1)
38-41: Unify terminology and optionally show disabled stateCurrent label (“Prompts Evals”) differs from bundle log (“Prompts evaluations”). Consider “Prompt Evaluations” everywhere and print both states for clarity.
-// Example of using feature flags -if IsPromptsEvalsEnabled() { - fmt.Println("Prompts Evals: Enabled") -} +// Feature flags +if IsPromptsEvalsEnabled() { + fmt.Println("Prompt Evaluations: Enabled") +} else { + fmt.Println("Prompt Evaluations: Disabled") +}cmd/bundle.go (1)
42-45: Align wording with version output; consider debug levelUse consistent phrasing (“Prompt Evaluations”) and optionally lower to Debug to reduce noise in normal runs.
-// Check for prompts evals feature flag -if IsPromptsEvalsEnabled() { - projectContext.Logger.Info("Prompts evaluations feature is enabled") -} +// Check for prompt evaluations feature flag +if IsPromptsEvalsEnabled() { + projectContext.Logger.Info("Prompt Evaluations feature is enabled") + // or: projectContext.Logger.Debug("Prompt Evaluations feature is enabled") +}cmd/root.go (1)
138-140: Enable Viper env overrides for dotted feature flags
In initConfig(), before viper.AutomaticEnv(), add:// allow env vars to override dotted keys viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) cobra.CheckErr(viper.BindEnv("features.enable_prompts_evals"))Also import "strings" at the top of cmd/root.go. This ensures FEATURES_ENABLE_PROMPTS_EVALS maps correctly to features.enable_prompts_evals.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
cmd/bundle.go(1 hunks)cmd/feature_flags.go(1 hunks)cmd/root.go(1 hunks)cmd/version.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
cmd/bundle.go (1)
cmd/feature_flags.go (1)
IsPromptsEvalsEnabled(31-33)
cmd/version.go (1)
cmd/feature_flags.go (1)
IsPromptsEvalsEnabled(31-33)
cmd/root.go (1)
cmd/feature_flags.go (1)
SetupFeatureFlags(14-21)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (go)
Summary by CodeRabbit
https://screen.studio/share/BiwDiMBl?state=uploading