Files
whatshooked/cmd/cli/commands_health.go
2025-12-29 05:29:53 +02:00

29 lines
524 B
Go

package main
import (
"fmt"
"github.com/spf13/cobra"
)
// healthCmd checks server health
var healthCmd = &cobra.Command{
Use: "health",
Short: "Check server health",
Run: func(cmd *cobra.Command, args []string) {
client := NewClient(cliConfig)
checkHealth(client)
},
}
func checkHealth(client *Client) {
resp, err := client.Get("/health")
checkError(err)
defer resp.Body.Close()
var result map[string]string
checkError(decodeJSON(resp, &result))
fmt.Printf("Server status: %s\n", result["status"])
}