-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add underscore variant #581
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR adds an underscore variant (read_only
) alongside the existing read-only
flag and updates the server configuration to respect both.
- Combines
viper.GetBool("read-only")
andviper.GetBool("read_only")
when setting theReadOnly
field - Registers two CLI flags (
--read-only
and--read_only
) bound to the samereadOnlyFlag
variable
Comments suppressed due to low confidence (1)
cmd/github-mcp-server/main.go:74
- The new
read_only
alias isn’t covered by any existing tests. Consider adding unit tests to verify that both--read-only
and--read_only
correctly enable read-only mode.
rootCmd.PersistentFlags().BoolVar(&readOnlyFlag, "read_only", false, "Restrict the server to read-only operations")
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.
I think this can be simplified and achieve the goal. Thanks for rapid fix.
@@ -69,6 +68,7 @@ func init() { | |||
rootCmd.PersistentFlags().StringSlice("toolsets", github.DefaultTools, "An optional comma separated list of groups of tools to allow, defaults to enabling all") | |||
rootCmd.PersistentFlags().Bool("dynamic-toolsets", false, "Enable dynamic toolsets") | |||
rootCmd.PersistentFlags().Bool("read-only", false, "Restrict the server to read-only operations") | |||
rootCmd.PersistentFlags().Bool("read_only", false, "Restrict the server to read-only operations") |
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.
I don't think we need the flag here, we can just allow viper env parser to fix the env version.
@@ -78,6 +78,7 @@ func init() { | |||
_ = viper.BindPFlag("toolsets", rootCmd.PersistentFlags().Lookup("toolsets")) | |||
_ = viper.BindPFlag("dynamic_toolsets", rootCmd.PersistentFlags().Lookup("dynamic-toolsets")) | |||
_ = viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only")) | |||
_ = viper.BindPFlag("read_only", rootCmd.PersistentFlags().Lookup("read_only")) |
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.
_ = viper.BindPFlag("read_only", rootCmd.PersistentFlags().Lookup("read_only")) |
@@ -69,6 +68,7 @@ func init() { | |||
rootCmd.PersistentFlags().StringSlice("toolsets", github.DefaultTools, "An optional comma separated list of groups of tools to allow, defaults to enabling all") | |||
rootCmd.PersistentFlags().Bool("dynamic-toolsets", false, "Enable dynamic toolsets") | |||
rootCmd.PersistentFlags().Bool("read-only", false, "Restrict the server to read-only operations") | |||
rootCmd.PersistentFlags().Bool("read_only", false, "Restrict the server to read-only operations") |
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.
rootCmd.PersistentFlags().Bool("read_only", false, "Restrict the server to read-only operations") |
@@ -91,6 +92,7 @@ func initConfig() { | |||
// Initialize Viper configuration | |||
viper.SetEnvPrefix("github") | |||
viper.AutomaticEnv() |
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 line gets the env vars, so the viper values will be set already.
Adds an underscore read_only flag.
Addresses: #577