Improve source query diagnostics

This commit is contained in:
2026-04-05 13:51:50 +03:00
parent cdf375ba80
commit 4c5dd0c5f4
3 changed files with 52 additions and 2 deletions

View File

@@ -29,6 +29,7 @@ func main() {
}
client := gamestatus.NewAll(cfg.timeout)
client.SetSourceDebug(cfg.debug)
info, err := connect(client, cfg.edition, host, port, cfg.useQuery)
if err != nil {
@@ -54,6 +55,7 @@ type cliConfig struct {
useQuery bool
pretty bool
motdRaw bool
debug bool
}
func parseCLI(args []string) (cliConfig, string, error) {
@@ -70,6 +72,7 @@ func parseCLI(args []string) (cliConfig, string, error) {
useQuery := fs.Bool("query", false, "use full query when supported")
pretty := fs.Bool("pretty", false, "use compact human-friendly output")
motdRaw := fs.Bool("motd-raw", false, "print raw MOTD without cleanup")
debug := fs.Bool("debug", false, "print protocol-specific diagnostics")
if len(args) > 0 {
switch strings.ToLower(strings.TrimSpace(args[0])) {
@@ -96,6 +99,7 @@ func parseCLI(args []string) (cliConfig, string, error) {
cfg.useQuery = *useQuery
cfg.pretty = *pretty
cfg.motdRaw = *motdRaw
cfg.debug = *debug
if fs.NArg() != 1 {
return cfg, "", nil
@@ -126,6 +130,8 @@ func printUsage() {
fmt.Fprintln(os.Stderr, " use compact human-friendly output")
fmt.Fprintln(os.Stderr, " -motd-raw")
fmt.Fprintln(os.Stderr, " print raw MOTD without cleanup")
fmt.Fprintln(os.Stderr, " -debug")
fmt.Fprintln(os.Stderr, " print protocol-specific diagnostics")
}
func connect(client *gamestatus.Client, edition, host string, port int, useQuery bool) (*gamestatus.ServerInfo, error) {