#!/bin/zsh

set -o pipefail

COMMANDS="
attach
build
builder
buildx imagetools
buildx bake
buildx build
buildx create
buildx du
buildx inspect
buildx ls
buildx prune
buildx rm
buildx stop
buildx use
buildx version
commit
compose build
compose convert
compose cp
compose create
compose down
compose events
compose exec
compose images
compose kill
compose logs
compose ls
compose pause
compose port
compose ps
compose pull
compose push
compose restart
compose rm
compose run
compose start
compose stop
compose top
compose unpause
compose up
compose version
config create
config inspect
config ls
config rm
container attach
container commit
container cp
container create
container diff
container exec
container export
container inspect
container kill
container logs
container ls
container pause
container port
container prune
container rename
container restart
container rm
container run
container start
container stats
container stop
container top
container unpause
container update
container wait
cp
create
diff
events
exec
export
help
history
image build
image history
image import
image inspect
image load
image ls
image prune
image pull
image push
image rm
image save
image tag
import
info
inspect
kill
load
login
logout
logs
manifest annotate
manifest create
manifest inspect
manifest push
manifest rm
network connect
network create
network disconnect
network inspect
network ls
network prune
network rm
node demote
node inspect
node ls
node promote
node ps
node rm
node update
pause
plugin create
plugin disable
plugin enable
plugin inspect
plugin install
plugin ls
plugin push
plugin rm
plugin set
plugin upgrade
port
ps
pull
push
rename
restart
rmi
rm
run
save
search
secret create
secret inspect
secret ls
secret rm
service create
service inspect
service logs
service ls
service ps
service rm
service rollback
service scale
service update
stack deploy
stack ls
stack ps
stack rm
stack services
start
stats
stop
swarm ca
swarm init
swarm join
swarm join-token
swarm leave
swarm unlock
swarm unlock-key
swarm update
system df
system events
system info
system prune
tag
top
trust key generate
trust key load
trust signer
trust inspect
trust revoke
trust sign
unpause
update
version
volume create
volume inspect
volume ls
volume prune
volume rm
wait
quit
"

while COMMAND=$(printf "$COMMANDS" | amen)
do
  if [ "$COMMAND" = "quit" ]
  then
    exit 0
  fi

  COMMAND="docker $COMMAND "
  zsh -c "$COMMAND --help"
  echo
  vared -p "> " -c COMMAND
  clear
  zsh -c "$COMMAND"
  echo

done
