2017-08-03 17:11:52 -04:00
|
|
|
#compdef packer
|
|
|
|
|
2017-08-02 03:18:38 -04:00
|
|
|
_packer () {
|
|
|
|
local -a sub_commands && sub_commands=(
|
2015-04-04 06:51:59 -04:00
|
|
|
'build:Build image(s) from template'
|
|
|
|
'fix:Fixes templates from old versions of packer'
|
|
|
|
'inspect:See components of a template'
|
|
|
|
'validate:Check that a template is valid'
|
|
|
|
'version:Prints the Packer version'
|
2017-08-02 03:18:38 -04:00
|
|
|
)
|
2015-04-04 06:51:59 -04:00
|
|
|
|
2017-08-02 03:18:38 -04:00
|
|
|
local -a build_arguments && build_arguments=(
|
2018-10-10 21:34:35 -04:00
|
|
|
'-debug[Debug mode enabled for builds.]'
|
|
|
|
'-force[Force a build to continue if artifacts exist, deletes existing artifacts.]'
|
|
|
|
'-machine-readable[Produce machine-readable output.]'
|
|
|
|
'-color=[(false) Disable color output. (Default: color)]'
|
2019-01-11 05:23:42 -05:00
|
|
|
'-except=[(foo,bar,baz) Run all builds and post-procesors other than these.]'
|
2018-10-10 21:34:35 -04:00
|
|
|
'-on-error=[(cleanup,abort,ask) If the build fails do: clean up (default), abort, or ask.]'
|
|
|
|
'-only=[(foo,bar,baz) Only build the given builds by name.]'
|
2019-05-02 10:01:35 -04:00
|
|
|
'-parallel=[(false) Disable parallelization. (Default: false)]'
|
|
|
|
'-parallel-builds=[(0) Number of builds to run in parallel. (Defaults to infinite: 0)]'
|
2017-08-02 03:18:38 -04:00
|
|
|
'-var[("key=value") Variable for templates, can be used multiple times.]'
|
2017-07-31 04:43:38 -04:00
|
|
|
'-var-file=[(path) JSON file containing user variables.]'
|
2017-08-02 03:18:38 -04:00
|
|
|
'(-)*:files:_files -g "*.json"'
|
|
|
|
)
|
2018-10-10 21:34:35 -04:00
|
|
|
|
2017-08-02 03:18:38 -04:00
|
|
|
local -a inspect_arguments && inspect_arguments=(
|
2018-10-10 21:34:35 -04:00
|
|
|
'-machine-readable[Machine-readable output]'
|
2017-08-02 03:18:38 -04:00
|
|
|
'(-)*:files:_files -g "*.json"'
|
|
|
|
)
|
2015-04-04 06:51:59 -04:00
|
|
|
|
2017-08-02 03:18:38 -04:00
|
|
|
local -a validate_arguments && validate_arguments=(
|
|
|
|
'-syntax-only[Only check syntax. Do not verify config of the template.]'
|
2019-09-26 07:13:02 -04:00
|
|
|
'-except=[(foo,bar,baz) Validate all builds other than these.]'
|
|
|
|
'-only=[(foo,bar,baz) Validate only these builds.]'
|
2017-08-02 03:18:38 -04:00
|
|
|
'-var[("key=value") Variable for templates, can be used multiple times.]'
|
2017-07-31 04:43:38 -04:00
|
|
|
'-var-file=[(path) JSON file containing user variables.]'
|
2017-08-02 03:18:38 -04:00
|
|
|
'(-)*:files:_files -g "*.json"'
|
|
|
|
)
|
2015-04-04 06:51:59 -04:00
|
|
|
|
2017-08-02 03:18:38 -04:00
|
|
|
_arguments -C \
|
|
|
|
':command:->command' \
|
|
|
|
'*::options:->options'
|
2015-04-04 06:51:59 -04:00
|
|
|
|
2017-08-02 03:18:38 -04:00
|
|
|
case $state in
|
|
|
|
command)
|
|
|
|
_describe -t commands 'command' sub_commands ;;
|
|
|
|
options)
|
|
|
|
case $line[1] in
|
|
|
|
build)
|
|
|
|
_arguments -s -S : $build_arguments ;;
|
|
|
|
inspect)
|
|
|
|
_arguments -s -S : $inspect_arguments ;;
|
|
|
|
validate)
|
|
|
|
_arguments -s -S : $validate_arguments ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
_packer "$@"
|