2016-02-29 14:14:38 +00:00
|
|
|
#compdef apex
|
|
|
|
|
|
|
|
__function_list() {
|
|
|
|
declare -a func_cmd
|
2016-03-01 00:06:23 +00:00
|
|
|
func_cmd=($(apex list 2>/dev/null | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | cut -d' ' -f3))
|
|
|
|
if [ -n "$func_cmd" ]
|
2016-02-29 14:14:38 +00:00
|
|
|
_describe 'functions' func_cmd
|
|
|
|
}
|
|
|
|
|
2016-03-01 00:06:23 +00:00
|
|
|
__deploy() {
|
|
|
|
_arguments \
|
|
|
|
'(-c|--concurrency)'{-c,--concurrency}'[Concurrent deploys (default 5)]'
|
|
|
|
__function_list
|
|
|
|
}
|
|
|
|
|
|
|
|
__invoke() {
|
|
|
|
_arguments \
|
|
|
|
'(-L|--logs)'{-l,--logs}'[Print logs]'
|
|
|
|
__function_list
|
|
|
|
}
|
|
|
|
|
|
|
|
__delete() {
|
|
|
|
_arguments \
|
|
|
|
'(-f|--force)'{-f,--force}'[Force deletion]'
|
|
|
|
__function_list
|
|
|
|
}
|
|
|
|
|
|
|
|
__rollback() {
|
|
|
|
if ((CURRENT == 3)); then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
__function_list
|
|
|
|
}
|
|
|
|
|
|
|
|
__build() {
|
|
|
|
if ((CURRENT == 3)); then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
__function_list
|
|
|
|
}
|
|
|
|
|
|
|
|
__list() {
|
|
|
|
_arguments \
|
|
|
|
'--tfvars[Output as Terraform variables]'
|
|
|
|
}
|
|
|
|
|
|
|
|
__metrics() {
|
|
|
|
_arguments \
|
|
|
|
'(-s,--start)'{-s,--start}'[Start time of the results (default 24h0m0s)]'
|
|
|
|
__function_list
|
|
|
|
}
|
|
|
|
|
|
|
|
__logs() {
|
|
|
|
_arguments \
|
|
|
|
'(-F,--filter)'{-f,--filter}'[Filter logs with pattern]' \
|
|
|
|
'(-f,--follow)'{-f,--filter}'[Follow tail logs for updates]' \
|
|
|
|
'(-s,--start)'{-s,--start}'[Start time of the search (default 5m0s)]'
|
|
|
|
__function_list
|
|
|
|
}
|
|
|
|
|
|
|
|
__docs() {
|
|
|
|
_arguments '*:files:_files'
|
|
|
|
}
|
|
|
|
|
2016-02-29 14:14:38 +00:00
|
|
|
local -a _1st_arguments
|
|
|
|
_1st_arguments=(
|
|
|
|
'deploy:Deploy functions and config'
|
|
|
|
'invoke:Invoke functions'
|
|
|
|
'delete:Delete functions'
|
|
|
|
'rollback:Rollback a function'
|
|
|
|
'build:Build a function'
|
|
|
|
'list:List functions'
|
|
|
|
'metrics:Output function metrics'
|
|
|
|
'logs:Output function logs'
|
|
|
|
'docs:Output documentation'
|
|
|
|
'version:Print version of Apex'
|
|
|
|
'upgrade:Ugrade apex to the latest stable release'
|
|
|
|
)
|
|
|
|
|
|
|
|
_arguments '*:: :->command'
|
|
|
|
|
|
|
|
if (( CURRENT == 1 )); then
|
|
|
|
_describe -t commands "apex command" _1st_arguments
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
local -a _command_args
|
|
|
|
case "$words[1]" in
|
|
|
|
deploy)
|
2016-03-01 00:06:23 +00:00
|
|
|
__deploy ;;
|
|
|
|
invoke)
|
|
|
|
__invoke ;;
|
|
|
|
delete)
|
|
|
|
__delete ;;
|
|
|
|
rollback)
|
|
|
|
__rollback ;;
|
|
|
|
build)
|
|
|
|
__build ;;
|
|
|
|
list)
|
|
|
|
__list ;;
|
|
|
|
metrics)
|
|
|
|
__metrics ;;
|
|
|
|
logs)
|
|
|
|
__logs ;;
|
|
|
|
docs)
|
|
|
|
__docs ;;
|
2016-02-29 14:14:38 +00:00
|
|
|
esac
|