add command tree

This commit is contained in:
2026-05-18 14:29:46 +02:00
parent 40e0612bef
commit 565d92b491
2 changed files with 70 additions and 23 deletions

View File

@@ -6,30 +6,46 @@ Elasticsearch CLI
## Usage
Command tree
```console
NAME:
esctl - manage elasticsearch from cli
USAGE:
esctl [global options] [command [command options]]
VERSION:
v0.0.4
COMMANDS:
search, / search within an index
index, i manage indicies
snapshot, snap manage snapshots
cluster, c manage cluster[s]
node, snap manage nodes
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--debug, -d enable debugging [$ES_DEBUG]
--config string, -c string config file [$ES_CONFIG]
--cluster string, -C string cluster alias to work with
--help, -h show help
--version, -v print the version
ccr
follower
add
delete
pause
renew
resume
show
unfollow
info
pause
resume
status
cluster
list
settings
list
set
status
doc
add
help
index
allocation
close
create
delete
list
show
node
list
show
repl
search
snapshot
list
show
```
Configure `esctl` with environment variables:

31
commandtree.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
getcommands() {
local command
command="$*"
if ! test "$command" = "help"; then
./esctl $command -h | sed -e '/^COMMANDS:/,/^$/!d;//d' -e 's/^ //' -e 's/[, ].*//' | sort
fi
}
printcommands() {
local indent basecommand commands command
indent="$1"
basecommand="$2"
commands="$3"
for command in $commands; do
echo "$indent" "$command"
commands=$(getcommands $basecommand $command)
if test -n "$commands"; then
printcommands "${indent} " "$basecommand $command" "$commands"
fi
done
}
commands=$(getcommands "")
printcommands "" "" "$commands"