Files
HarborForge.Cli/internal/commands/health.go
zhi 7d3cff7d95 feat: implement core CLI packages and Phase 3 commands
- config: resolve binary dir, load/save .hf-config.json
- mode: detect padded-cell vs manual mode via pass_mgr
- client: HTTP client wrapper with auth header support
- passmgr: pass_mgr integration (get-secret, set, generate)
- output: human-readable + JSON output formatting with tables
- help: help and help-brief renderer for groups/commands
- commands: version, health, config (--url, --acc-mgr-token, show)
- auth: token resolution helper (padded-cell auto / manual explicit)
- main: command dispatcher with --json global flag support
- README: updated with current package layout and status
2026-03-21 13:50:29 +00:00

33 lines
744 B
Go

package commands
import (
"fmt"
"git.hangman-lab.top/zhi/HarborForge.Cli/internal/client"
"git.hangman-lab.top/zhi/HarborForge.Cli/internal/config"
"git.hangman-lab.top/zhi/HarborForge.Cli/internal/output"
)
// RunHealth checks the HarborForge API health endpoint.
func RunHealth() {
cfg, err := config.Load()
if err != nil {
output.Errorf("config error: %v", err)
}
c := client.New(cfg.BaseURL, "")
result, err := c.Health()
if err != nil {
output.Errorf("health check failed: %v", err)
}
if output.JSONMode {
output.PrintJSON(result)
} else {
status, _ := result["status"].(string)
if status == "" {
status = "unknown"
}
fmt.Printf("HarborForge API: %s\n", status)
fmt.Printf("URL: %s\n", cfg.BaseURL)
}
}