add searchql and help-esql commands

This commit is contained in:
2026-07-10 15:04:41 +02:00
parent 15dbf7ada0
commit 374ff99916
6 changed files with 1083 additions and 2 deletions

View File

@@ -24,10 +24,13 @@ import (
"runtime/pprof"
"strings"
"codeberg.org/scip/esctl/assets"
"codeberg.org/scip/esctl/pkg/cfg"
"codeberg.org/scip/esctl/pkg/es"
"codeberg.org/scip/esctl/pkg/log"
"codeberg.org/scip/esctl/pkg/printer"
markdown "github.com/MichaelMure/go-term-markdown"
"github.com/urfave/cli/v3"
)
@@ -141,7 +144,7 @@ func Main() int {
Name: "output",
Aliases: []string{"o"},
Value: "",
Usage: "output mode (tsv, json, yaml) default: tsv",
Usage: "output mode (tsv, csv, json, yaml) default: tsv",
Destination: &conf.Output,
},
&cli.StringFlag{
@@ -164,6 +167,7 @@ func Main() int {
Node(conf),
Roles(conf),
Search(conf),
SearchQL(conf),
Shard(conf),
Snapshot(conf),
Task(conf),
@@ -171,6 +175,7 @@ func Main() int {
Debug(conf),
HelpJsonPath(conf),
HelpUsage(conf),
HelpEsQl(conf),
},
Before: func(ctx context.Context, cmd *cli.Command) (context.Context, error) {
@@ -226,6 +231,20 @@ func HelpJsonPath(conf *cfg.Config) *cli.Command {
}
}
func HelpEsQl(conf *cfg.Config) *cli.Command {
return &cli.Command{
Name: "help-esql",
Usage: "show esql help",
Action: func(ctx context.Context, cmd *cli.Command) error {
assets.LoadEsql()
width := cfg.GetTermWidth()
printer.Pager("esql cheat sheet", string(markdown.Render(assets.EsQlCheatSheet, width, cfg.DefaultMargin)))
return nil
},
}
}
func Version(conf *cfg.Config) *cli.Command {
return &cli.Command{
Name: "version",