package main import ( "context" "fmt" "time" "github.com/spf13/cobra" "git.wntrmute.dev/kyle/mc-proxy/client/mcproxy" ) func healthCmd() *cobra.Command { return &cobra.Command{ Use: "health", Short: "Check server health", Long: "Check the health status of the mc-proxy server.", RunE: func(cmd *cobra.Command, args []string) error { client := clientFromContext(cmd.Context()) ctx, cancel := context.WithTimeout(cmd.Context(), 5*time.Second) defer cancel() status, err := client.CheckHealth(ctx) if err != nil { return fmt.Errorf("checking health: %w", err) } fmt.Println(status) if status != mcproxy.HealthServing { return fmt.Errorf("server is not healthy") } return nil }, } }