Skip to content

Instantly share code, notes, and snippets.

@aoshiman
Last active October 30, 2016 12:29
Show Gist options
  • Save aoshiman/d2e93f986802f5a359b4dc6f25eff1a3 to your computer and use it in GitHub Desktop.
Save aoshiman/d2e93f986802f5a359b4dc6f25eff1a3 to your computer and use it in GitHub Desktop.
#compdef lamvery
__lamvery_commands () {
local -a _c
_c=(
'init:Generate initial configuration file'
'build:Build and archive your code and libraries to <your-function-name>.zip'
'set-alias:Set alias to a version of the function'
'configure:Update the remote configuration'
'deploy:Deploy your code and libraries,Update the remote configuration, Set alias (optional)'
'encrypt:Encrypt a text value using KMS'
'decrypt:Decrypt the secret value using KMS'
'encrypt-file:Encrypt a file using KMS'
'events:Configure all events of CloudWatchEvents using the function'
'invoke:Invoke the function'
'rollback:Rollback your code and libraries'
'logs:Watch the function'\''s log events on CloudWatch Logs'
'api:Manage your APIs'
'generate:Ganerate skeleton files'
)
_describe -t commands Commands _c
}
function _lamvery () {
local context curcontext=$curcontext state line
declare -A opt_args
local ret=1
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'1: :__lamvery_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(api)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-d --dry-run)'{-d,--dry-run}'[Dry run]' \
'(-n --no-integrate)'{-n,--no-integrate}'[Without automatic integration]' \
'(-r --remove)'{-r,--remove}'[Remove your API]' \
'(-s --stage)'{-s,--stage}'[The name of the stage in API Gateway]' \
'(-w --write-id)'{-w,--write-id}'[Write the id of your API to the configuration file(default: .lamvery.api.yml)]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(build)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-s --single-file)'{-s,--single-file}'[Only use the main lambda function file]' \
'(-l --no-libs)'{-l,--no-libs}'[Archiving without all libraries]' \
'(-e --env)'{-e,--env}'[Environment variables that pass to the function]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(configure)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-d --dry-run)'{-d,--dry-run}'[Dry run]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(decrypt)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-n --secret-name)'{-n,--secret-name}'[The name of the secret value]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(deploy)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-a --alias)'{-a,--alias}'[Alias for a version of the function]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-d --dry-run)'{-d,--dry-run}'[Dry run]' \
'(-s --single-file)'{-s,--single-file}'[Only use the main lambda function file]' \
'(-l --no-libs)'{-l,--no-libs}'[Archiving without all libraries]' \
'(-p --publish)'{-p,--publish}'[Publish the version as an atomic operation]' \
'(-e --env)'{-e,--env}'[Environment variables that pass to the function]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(encrypt)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-n --secret-name)'{-n,--secret-name}'[The name of the secret value]' \
'(-s --store)'{-s,--store}'[Store encripted value to the configuration file (default: .lamvery.secret.yml)]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(encrypt-file)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-n --name)'{-n,--name}'[iThe filename to put the decrypted file in the function environment]' \
'(-s --store)'{-s,--store}'[Store encripted value to the configuration file (default: .lamvery.secret.yml)]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(event)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-a --alias)'{-a,--alias}'[Alias for a version of the function]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-d --dry-run)'{-d,--dry-run}'[Dry run]' \
'(-k --keep-empty-evets)'{-k,--keep-empty-events}'[Keep the event rules that does not have any targets.]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(generate)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-k --kind)'{-k,--kind}'[The kind of the file # accepts "function"]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(init)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-)*:: :->null_state' \
&& ret=0
;;
(invoke)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-a --alias)'{-a,--alias}'[Alias for a version of the function]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-v --version)'{-v,--version}'[Version of the function]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(logs)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-f --follow)'{-f,--follow}'[Watch the log events and updates the display (like `tail -f`)]' \
'(-F --filter)'{-F,--filter}'[Filtering pattern for the log messages]' \
'(-i --interval)'{-i,--interval}'[Intervals(seconds) to watch the log events]' \
'(-s --start)'{-s,--start}'[Time to start the log events watching]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(rollback)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-a --alias)'{-a,--alias}'[Alias for a version of the function]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-v --version)'{-v,--version}'[Version of the function]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(set-alias)
_arguments -C \
'(-h --help)'{-h,--help}'[show this help message and exit]' \
'(-a --alias)'{-a,--alias}'[Alias for a version of the function]' \
'(-c --conf-file)'{-c,--conf-file}'[Configuration YAML file (default: .lamvery.yml)]:CONF_FILE:_files' \
'(-d --dry-run)'{-d,--dry-run}'[Dry run]' \
'(-v --version)'{-v,--version}'[Version of the function]' \
'(-t --target)'{-t,--target}'[The alias of the version that is targeted for setting alias]' \
'(-)*:: :->null_state' \
&& ret=0
;;
esac
;;
esac
return ret
}
_lamvery "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment