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