CLI refactor

This commit is contained in:
2025-12-29 05:29:53 +02:00
parent d54b0eaddf
commit 16aaf1919d
9 changed files with 1111 additions and 585 deletions

View 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"])
}