add index ls command, add table and color support

This commit is contained in:
2026-04-21 15:05:15 +02:00
parent 2b21fa0e7e
commit a7d979ca38
12 changed files with 344 additions and 18 deletions

View File

@@ -18,6 +18,7 @@ package es
import (
"context"
"fmt"
"log"
"log/slog"
@@ -30,7 +31,20 @@ func Health(conf *cfg.Config) error {
log.Fatalf("Error getting health: %s", err)
}
slog.Info("ES result", "cluster health", res)
slog.Debug("ES result", "cluster health", res)
table := NewTable(5)
table.headers = []string{bold("SETTING"), bold("STATUS")}
table.entries = [][]string{
{"Cluster Name", Colorize(*&res.Status.Name, res.ClusterName)},
{"Active Shards", fmt.Sprintf("%d", res.ActiveShards)},
{"Active Primary Shards", fmt.Sprintf("%d", res.ActivePrimaryShards)},
{"Indicies", fmt.Sprintf("%d", len(res.Indices))},
{"Nodes", fmt.Sprintf("%d", res.NumberOfNodes)},
}
table.PrintMarkdown()
return nil
}