Skip to content

Commit ecc57ff

Browse files
JoannaaKLSamMorrowDrums
authored andcommitted
Update main.go
1 parent 76535ee commit ecc57ff

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

cmd/github-mcp-server/main.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import (
44
"errors"
55
"fmt"
66
"os"
7+
"strings"
78

89
"github.com/github/github-mcp-server/internal/ghmcp"
910
"github.com/github/github-mcp-server/pkg/github"
1011
"github.com/spf13/cobra"
12+
"github.com/spf13/pflag"
1113
"github.com/spf13/viper"
1214
)
1315

@@ -49,7 +51,7 @@ var (
4951
Token: token,
5052
EnabledToolsets: enabledToolsets,
5153
DynamicToolsets: viper.GetBool("dynamic_toolsets"),
52-
ReadOnly: viper.GetBool("read-only") || viper.GetBool("read_only"),
54+
ReadOnly: viper.GetBool("read-only"),
5355
ExportTranslations: viper.GetBool("export-translations"),
5456
EnableCommandLogging: viper.GetBool("enable-command-logging"),
5557
LogFilePath: viper.GetString("log-file"),
@@ -61,14 +63,14 @@ var (
6163

6264
func init() {
6365
cobra.OnInitialize(initConfig)
66+
rootCmd.SetGlobalNormalizationFunc(wordSepNormalizeFunc)
6467

6568
rootCmd.SetVersionTemplate("{{.Short}}\n{{.Version}}\n")
6669

6770
// Add global flags that will be shared by all commands
6871
rootCmd.PersistentFlags().StringSlice("toolsets", github.DefaultTools, "An optional comma separated list of groups of tools to allow, defaults to enabling all")
6972
rootCmd.PersistentFlags().Bool("dynamic-toolsets", false, "Enable dynamic toolsets")
7073
rootCmd.PersistentFlags().Bool("read-only", false, "Restrict the server to read-only operations")
71-
rootCmd.PersistentFlags().Bool("read_only", false, "Restrict the server to read-only operations")
7274
rootCmd.PersistentFlags().String("log-file", "", "Path to log file")
7375
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
7476
rootCmd.PersistentFlags().Bool("export-translations", false, "Save translations to a JSON file")
@@ -78,7 +80,6 @@ func init() {
7880
_ = viper.BindPFlag("toolsets", rootCmd.PersistentFlags().Lookup("toolsets"))
7981
_ = viper.BindPFlag("dynamic_toolsets", rootCmd.PersistentFlags().Lookup("dynamic-toolsets"))
8082
_ = viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only"))
81-
_ = viper.BindPFlag("read_only", rootCmd.PersistentFlags().Lookup("read_only"))
8283
_ = viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
8384
_ = viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
8485
_ = viper.BindPFlag("export-translations", rootCmd.PersistentFlags().Lookup("export-translations"))
@@ -101,3 +102,12 @@ func main() {
101102
os.Exit(1)
102103
}
103104
}
105+
106+
func wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
107+
from := []string{"_"}
108+
to := "-"
109+
for _, sep := range from {
110+
name = strings.Replace(name, sep, to, -1)
111+
}
112+
return pflag.NormalizedName(name)
113+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy