Format status output

This commit is contained in:
2026-06-24 14:04:53 -04:00
parent 4296a2e066
commit 06f7ab1ee3

View File

@@ -3,7 +3,6 @@ package server
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"log"
"os/exec" "os/exec"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@@ -21,8 +20,16 @@ func Status(cmd *cobra.Command, args []string) {
start_cmd.Stderr = &errb start_cmd.Stderr = &errb
if err := start_cmd.Run(); err != nil { if err := start_cmd.Run(); err != nil {
log.Fatal(err) fmt.Print("offline")
return
} }
fmt.Println(outb.String()) var active, max int
_, err := fmt.Sscanf(outb.String(), "There are %d of a max of %d players online:", &active, &max)
if err != nil {
panic(err)
}
fmt.Printf("%d/%d players", active, max)
} }