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

remove pretty print json flag#179

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mntlty merged 1 commit intomainfromremove_pretty_print_json
Apr 8, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletionscmd/github-mcp-server/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
package main

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
stdlog "log"
Expand DownExpand Up@@ -41,7 +39,6 @@ var (
logFile := viper.GetString("log-file")
readOnly := viper.GetBool("read-only")
exportTranslations := viper.GetBool("export-translations")
prettyPrintJSON := viper.GetBool("pretty-print-json")
logger, err := initLogger(logFile)
if err != nil {
stdlog.Fatal("Failed to initialize logger:", err)
Expand All@@ -52,7 +49,6 @@ var (
logger: logger,
logCommands: logCommands,
exportTranslations: exportTranslations,
prettyPrintJSON: prettyPrintJSON,
}
if err := runStdioServer(cfg); err != nil {
stdlog.Fatal("failed to run stdio server:", err)
Expand All@@ -70,15 +66,13 @@ func init() {
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
rootCmd.PersistentFlags().Bool("export-translations", false, "Save translations to a JSON file")
rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")
rootCmd.PersistentFlags().Bool("pretty-print-json", false, "Pretty print JSON output")

// Bind flag to viper
_ = viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only"))
_ = viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
_ = viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
_ = viper.BindPFlag("export-translations", rootCmd.PersistentFlags().Lookup("export-translations"))
_ = viper.BindPFlag("gh-host", rootCmd.PersistentFlags().Lookup("gh-host"))
_ = viper.BindPFlag("pretty-print-json", rootCmd.PersistentFlags().Lookup("pretty-print-json"))

// Add subcommands
rootCmd.AddCommand(stdioCmd)
Expand DownExpand Up@@ -112,20 +106,6 @@ type runConfig struct {
logger *log.Logger
logCommands bool
exportTranslations bool
prettyPrintJSON bool
}

// JSONPrettyPrintWriter is a Writer that pretty prints input to indented JSON
type JSONPrettyPrintWriter struct {
writer io.Writer
}

func (j JSONPrettyPrintWriter) Write(p []byte) (n int, err error) {
var prettyJSON bytes.Buffer
if err := json.Indent(&prettyJSON, p, "", "\t"); err != nil {
return 0, err
}
return j.writer.Write(prettyJSON.Bytes())
}

func runStdioServer(cfg runConfig) error {
Expand DownExpand Up@@ -179,9 +159,6 @@ func runStdioServer(cfg runConfig) error {
in, out = loggedIO, loggedIO
}

if cfg.prettyPrintJSON {
out = JSONPrettyPrintWriter{writer: out}
}
errC <- stdioServer.Listen(ctx, in, out)
}()

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp