Files
blackroad-cli/internal/commands/status.go

62 lines
1.5 KiB
Go

package commands
import (
"fmt"
"github.com/BlackRoad-OS/blackroad-cli/internal/api"
"github.com/spf13/cobra"
)
var statusCmd = &cobra.Command{
Use: "status",
Short: "Show BlackRoad status",
Long: "Display overall BlackRoad infrastructure status including API health and statistics.",
Run: func(cmd *cobra.Command, args []string) {
client, err := api.NewClient()
if err != nil {
printError(err.Error())
return
}
// Get health
health, err := client.Health()
if err != nil {
printError(fmt.Sprintf("API unreachable: %v", err))
return
}
fmt.Printf("%s\n\n", bold(cyan("BlackRoad Status")))
// API Health
statusIcon := green("●")
if health.Status != "healthy" {
statusIcon = red("●")
}
fmt.Printf("%s %s API %s (v%s)\n", statusIcon, bold("API:"), health.Status, health.Version)
// Get stats
agentStats, _ := client.AgentStats()
taskStats, _ := client.TaskStats()
memoryStats, _ := client.MemoryStats()
fmt.Println()
fmt.Printf("%s\n", bold("Statistics"))
if agentStats != nil {
fmt.Printf(" %s %d total, %d active\n", cyan("Agents:"), agentStats.Total, agentStats.Active)
}
if taskStats != nil {
fmt.Printf(" %s %d total, %d pending, %d completed\n",
cyan("Tasks:"), taskStats.Total, taskStats.Pending, taskStats.Completed)
}
if memoryStats != nil {
fmt.Printf(" %s %d entries\n", cyan("Memory:"), memoryStats.Total)
}
fmt.Println()
fmt.Printf("%s All systems operational\n", green("✓"))
},
}