Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit936b24c

Browse files
authored
remove pretty print json flag (github#179)
1 parent4cf96ab commit936b24c

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

‎cmd/github-mcp-server/main.go

Lines changed: 0 additions & 23 deletions
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
iferr!=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
iferr:=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
logCommandsbool
114108
exportTranslationsbool
115-
prettyPrintJSONbool
116-
}
117-
118-
// JSONPrettyPrintWriter is a Writer that pretty prints input to indented JSON
119-
typeJSONPrettyPrintWriterstruct {
120-
writer io.Writer
121-
}
122-
123-
func (jJSONPrettyPrintWriter)Write(p []byte) (nint,errerror) {
124-
varprettyJSON bytes.Buffer
125-
iferr:=json.Indent(&prettyJSON,p,"","\t");err!=nil {
126-
return0,err
127-
}
128-
returnj.writer.Write(prettyJSON.Bytes())
129109
}
130110

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp