Dave Cross: Still Munging Data With Perl: Online event - Mar 17 Learn more

#compdef digitaloceancl
_digitaloceancl() {
local program=digitaloceancl
typeset -A opt_args
local curcontext="$curcontext" state line context
# ---- Command:
_arguments -s \
'1: :->cmd1' \
'*: :->args' \
&& ret=0
case $state in
cmd1)
_alternative 'args:cmd2:((GET\:"GET call" POST\:"POST call" help\:"Show command help"))'
;;
args)
case $line[1] in
GET)
# ---- Command: GET
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'*: :->args' \
&& ret=0
case $state in
cmd2)
_alternative 'args:cmd3:((/account\:"Account information" /droplets\:"List all droplets" /droplets/\\:id\:"Retrieve a droplet by id"))'
;;
args)
case $line[2] in
/account)
# ---- Command: GET /account
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
&& ret=0
;;
/droplets)
# ---- Command: GET /droplets
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
&& ret=0
;;
/droplets/:id)
# ---- Command: GET /droplets/:id
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->id' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
&& ret=0
case $state in
id)
;;
esac
;;
esac
;;
esac
;;
POST)
# ---- Command: POST
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'*: :->args' \
&& ret=0
case $state in
cmd2)
_alternative 'args:cmd3:((/droplets/\\:id/actions\:"Trigger droplet action"))'
;;
args)
case $line[2] in
/droplets/:id/actions)
# ---- Command: POST /droplets/:id/actions
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
&& ret=0
;;
esac
;;
esac
;;
_meta)
# ---- Command: _meta
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'*: :->args' \
&& ret=0
case $state in
cmd2)
_alternative 'args:cmd3:((completion\:"Shell completion functions" pod\:"Pod documentation"))'
;;
args)
case $line[2] in
completion)
# ---- Command: _meta completion
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'*: :->args' \
&& ret=0
case $state in
cmd3)
_alternative 'args:cmd4:((generate\:"Generate self completion"))'
;;
args)
case $line[3] in
generate)
# ---- Command: _meta completion generate
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
'--name[name of the program (optional, override name in spec)]:name' \
'--zsh[for zsh]' \
'--bash[for bash]' \
&& ret=0
;;
esac
;;
esac
;;
pod)
# ---- Command: _meta pod
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'*: :->args' \
&& ret=0
case $state in
cmd3)
_alternative 'args:cmd4:((generate\:"Generate self pod"))'
;;
args)
case $line[3] in
generate)
# ---- Command: _meta pod generate
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
&& ret=0
;;
esac
;;
esac
;;
esac
;;
esac
;;
help)
# ---- Command: help
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'*: :->args' \
&& ret=0
case $state in
cmd2)
_alternative 'args:cmd3:((GET POST))'
;;
args)
case $line[2] in
GET)
# ---- Command: help GET
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'*: :->args' \
&& ret=0
case $state in
cmd3)
_alternative 'args:cmd4:((/account /droplets /droplets/\\:id))'
;;
args)
case $line[3] in
/account)
# ---- Command: help GET /account
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' \
&& ret=0
;;
/droplets)
# ---- Command: help GET /droplets
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' \
&& ret=0
;;
/droplets/:id)
# ---- Command: help GET /droplets/:id
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' \
&& ret=0
;;
esac
;;
esac
;;
POST)
# ---- Command: help POST
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'*: :->args' \
&& ret=0
case $state in
cmd3)
_alternative 'args:cmd4:((/droplets/\\:id/actions))'
;;
args)
case $line[3] in
/droplets/:id/actions)
# ---- Command: help POST /droplets/:id/actions
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' \
&& ret=0
;;
esac
;;
esac
;;
_meta)
# ---- Command: help _meta
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'*: :->args' \
&& ret=0
case $state in
cmd3)
_alternative 'args:cmd4:((completion pod))'
;;
args)
case $line[3] in
completion)
# ---- Command: help _meta completion
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'4: :->cmd4' \
'*: :->args' \
&& ret=0
case $state in
cmd4)
_alternative 'args:cmd5:((generate))'
;;
args)
case $line[4] in
generate)
# ---- Command: help _meta completion generate
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'4: :->cmd4' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' \
&& ret=0
;;
esac
;;
esac
;;
pod)
# ---- Command: help _meta pod
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'4: :->cmd4' \
'*: :->args' \
&& ret=0
case $state in
cmd4)
_alternative 'args:cmd5:((generate))'
;;
args)
case $line[4] in
generate)
# ---- Command: help _meta pod generate
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'3: :->cmd3' \
'4: :->cmd4' \
'--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
'--debug[debug]' \
'-d[debug]' \
'--verbose[verbose]' \
'-v[verbose]' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' \
&& ret=0
;;
esac
;;
esac
;;
esac
;;
esac
;;
esac
;;
esac
;;
esac
;;
esac
}
__digitaloceancl_dynamic_comp() {
local argname="$1"
local arg="$2"
local comp="arg:$argname:(("
local line
while read -r line; do
local name="$line"
local desc="$line"
name="${name%$'\t'*}"
desc="${desc/*$'\t'}"
comp="$comp$name"
if [[ -n "$desc" && "$name" != "$desc" ]]; then
comp="$comp\\:"'"'"$desc"'"'
fi
comp="$comp "
done <<< "$arg"
comp="$comp))"
_alternative "$comp"
}