Skip to content

Commit 936b24c

Browse files
authored
remove pretty print json flag (#179)
1 parent 4cf96ab commit 936b24c

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

cmd/github-mcp-server/main.go

-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package main
22

33
import (
4-
"bytes"
54
"context"
6-
"encoding/json"
75
"fmt"
86
"io"
97
stdlog "log"
@@ -41,7 +39,6 @@ var (
4139
logFile := viper.GetString("log-file")
4240
readOnly := viper.GetBool("read-only")
4341
exportTranslations := viper.GetBool("export-translations")
44-
prettyPrintJSON := viper.GetBool("pretty-print-json")
4542
logger, err := initLogger(logFile)
4643
if err != nil {
4744
stdlog.Fatal("Failed to initialize logger:", err)
@@ -52,7 +49,6 @@ var (
5249
logger: logger,
5350
logCommands: logCommands,
5451
exportTranslations: exportTranslations,
55-
prettyPrintJSON: prettyPrintJSON,
5652
}
5753
if err := runStdioServer(cfg); err != nil {
5854
stdlog.Fatal("failed to run stdio server:", err)
@@ -70,15 +66,13 @@ func init() {
7066
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
7167
rootCmd.PersistentFlags().Bool("export-translations", false, "Save translations to a JSON file")
7268
rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")
73-
rootCmd.PersistentFlags().Bool("pretty-print-json", false, "Pretty print JSON output")
7469

7570
// Bind flag to viper
7671
_ = viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only"))
7772
_ = viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
7873
_ = viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
7974
_ = viper.BindPFlag("export-translations", rootCmd.PersistentFlags().Lookup("export-translations"))
8075
_ = viper.BindPFlag("gh-host", rootCmd.PersistentFlags().Lookup("gh-host"))
81-
_ = viper.BindPFlag("pretty-print-json", rootCmd.PersistentFlags().Lookup("pretty-print-json"))
8276

8377
// Add subcommands
8478
rootCmd.AddCommand(stdioCmd)
@@ -112,20 +106,6 @@ type runConfig struct {
112106
logger *log.Logger
113107
logCommands bool
114108
exportTranslations bool
115-
prettyPrintJSON bool
116-
}
117-
118-
// JSONPrettyPrintWriter is a Writer that pretty prints input to indented JSON
119-
type JSONPrettyPrintWriter struct {
120-
writer io.Writer
121-
}
122-
123-
func (j JSONPrettyPrintWriter) Write(p []byte) (n int, err error) {
124-
var prettyJSON bytes.Buffer
125-
if err := json.Indent(&prettyJSON, p, "", "\t"); err != nil {
126-
return 0, err
127-
}
128-
return j.writer.Write(prettyJSON.Bytes())
129109
}
130110

131111
func runStdioServer(cfg runConfig) error {
@@ -179,9 +159,6 @@ func runStdioServer(cfg runConfig) error {
179159
in, out = loggedIO, loggedIO
180160
}
181161

182-
if cfg.prettyPrintJSON {
183-
out = JSONPrettyPrintWriter{writer: out}
184-
}
185162
errC <- stdioServer.Listen(ctx, in, out)
186163
}()
187164

0 commit comments

Comments
 (0)