CLI refactor
This commit is contained in:
28
cmd/cli/commands_health.go
Normal file
28
cmd/cli/commands_health.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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"])
|
||||
}
|
||||
Reference in New Issue
Block a user