#compdef cfn-guard

autoload -U is-at-least

_cfn-guard() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_cfn-guard_commands" \
"*::: :->cfn-guard" \
&& ret=0
    case $state in
    (cfn-guard)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:cfn-guard-command-$line[1]:"
        case $line[1] in
            (validate)
_arguments "${_arguments_options[@]}" : \
'(-P --payload)*-r+[Provide a rules file or a directory of rules files. Supports passing multiple values by using this option repeatedly. Example\:  --rules rule1.guard --rules ./rules-dir1 --rules rule2.guard For directory arguments such as \`rules-dir1\` above, scanning is only supported for files with following extensions\: .guard, .ruleset]' \
'(-P --payload)*--rules=[Provide a rules file or a directory of rules files. Supports passing multiple values by using this option repeatedly. Example\:  --rules rule1.guard --rules ./rules-dir1 --rules rule2.guard For directory arguments such as \`rules-dir1\` above, scanning is only supported for files with following extensions\: .guard, .ruleset]' \
'(-P --payload)*-d+[Provide a data file or directory of data files in JSON or YAML. Supports passing multiple values by using this option repeatedly. Example\:  --data template1.yaml --data ./data-dir1 --data template2.yaml For directory arguments such as \`data-dir1\` above, scanning is only supported for files with following extensions\: .yaml, .yml, .json, .jsn, .template]' \
'(-P --payload)*--data=[Provide a data file or directory of data files in JSON or YAML. Supports passing multiple values by using this option repeatedly. Example\:  --data template1.yaml --data ./data-dir1 --data template2.yaml For directory arguments such as \`data-dir1\` above, scanning is only supported for files with following extensions\: .yaml, .yml, .json, .jsn, .template]' \
'*-i+[Provide a parameter file or directory of parameter files in JSON or YAML that specifies any additional parameters to use along with data files to be used as a combined context. All the parameter files passed as input get merged and this combined context is again merged with each file passed as an argument for \`data\`. Due to this, every file is expected to contain mutually exclusive properties, without any overlap. Supports passing multiple values by using this option repeatedly. Example\:  --input-parameters param1.yaml --input-parameters ./param-dir1 --input-parameters param2.yaml For directory arguments such as \`param-dir1\` above, scanning is only supported for files with following extensions\: .yaml, .yml, .json, .jsn, .template]' \
'*--input-params=[Provide a parameter file or directory of parameter files in JSON or YAML that specifies any additional parameters to use along with data files to be used as a combined context. All the parameter files passed as input get merged and this combined context is again merged with each file passed as an argument for \`data\`. Due to this, every file is expected to contain mutually exclusive properties, without any overlap. Supports passing multiple values by using this option repeatedly. Example\:  --input-parameters param1.yaml --input-parameters ./param-dir1 --input-parameters param2.yaml For directory arguments such as \`param-dir1\` above, scanning is only supported for files with following extensions\: .yaml, .yml, .json, .jsn, .template]' \
'-t+[Specify the type of data file used for improved messaging - ex\: CFNTemplate]:type:(CFNTemplate)' \
'--type=[Specify the type of data file used for improved messaging - ex\: CFNTemplate]:type:(CFNTemplate)' \
'-o+[Specify the format in which the output should be displayed]:OUTPUT_FORMAT:(single-line-summary json yaml junit sarif)' \
'--output-format=[Specify the format in which the output should be displayed]:OUTPUT_FORMAT:(single-line-summary json yaml junit sarif)' \
'*-S+[Controls if the summary table needs to be displayed. --show-summary fail (default) or --show-summary pass,fail (only show rules that did pass/fail) or --show-summary none (to turn it off) or --show-summary all (to show all the rules that pass, fail or skip)]:SHOW_SUMMARY:(all pass fail skip none)' \
'*--show-summary=[Controls if the summary table needs to be displayed. --show-summary fail (default) or --show-summary pass,fail (only show rules that did pass/fail) or --show-summary none (to turn it off) or --show-summary all (to show all the rules that pass, fail or skip)]:SHOW_SUMMARY:(all pass fail skip none)' \
'(-m --last-modified)-a[Validate files in a directory ordered alphabetically]' \
'(-m --last-modified)--alphabetical[Validate files in a directory ordered alphabetically]' \
'(-a --alphabetical)-m[Validate files in a directory ordered by last modified times]' \
'(-a --alphabetical)--last-modified[Validate files in a directory ordered by last modified times]' \
'-v[Verbose logging]' \
'--verbose[Verbose logging]' \
'-p[Print the parse tree in a json format. This can be used to get more details on how the clauses were evaluated]' \
'--print-json[Print the parse tree in a json format. This can be used to get more details on how the clauses were evaluated]' \
'-P[Provide rules and data in the following JSON format via STDIN, {"rules"\:\["<rules 1>", "<rules 2>", ...\], "data"\:\["<data 1>", "<data 2>", ...\]}, where, - "rules" takes a list of string version of rules files as its value and - "data" takes a list of string version of data files as it value. When --payload is specified --rules and --data cannot be specified.]' \
'--payload[Provide rules and data in the following JSON format via STDIN, {"rules"\:\["<rules 1>", "<rules 2>", ...\], "data"\:\["<data 1>", "<data 2>", ...\]}, where, - "rules" takes a list of string version of rules files as its value and - "data" takes a list of string version of data files as it value. When --payload is specified --rules and --data cannot be specified.]' \
'(-p --print-json -v --verbose)-z[Print out a list of structured and valid JSON/YAML. This argument conflicts with the following arguments\:  verbose   print-json   show-summary\: all/fail/pass/skip  output-format\: single-line-summary]' \
'(-p --print-json -v --verbose)--structured[Print out a list of structured and valid JSON/YAML. This argument conflicts with the following arguments\:  verbose   print-json   show-summary\: all/fail/pass/skip  output-format\: single-line-summary]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
'-r+[Provide a rules file]:rules-file:_default' \
'--rules-file=[Provide a rules file]:rules-file:_default' \
'-t+[Provide a file or dir for data files in JSON or YAML]:test-data:_default' \
'--test-data=[Provide a file or dir for data files in JSON or YAML]:test-data:_default' \
'-d+[Provide the root directory for rules]:dir:_default' \
'--dir=[Provide the root directory for rules]:dir:_default' \
'-o+[Specify the format in which the output should be displayed]:OUTPUT_FORMAT:(single-line-summary json yaml junit sarif)' \
'--output-format=[Specify the format in which the output should be displayed]:OUTPUT_FORMAT:(single-line-summary json yaml junit sarif)' \
'(-m --last-modified)-a[Sort alphabetically inside a directory]' \
'(-m --last-modified)--alphabetical[Sort alphabetically inside a directory]' \
'(-a --alphabetical)-m[Sort by last modified times within a directory]' \
'(-a --alphabetical)--last-modified[Sort by last modified times within a directory]' \
'-v[Verbose logging]' \
'--verbose[Verbose logging]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(parse-tree)
_arguments "${_arguments_options[@]}" : \
'-r+[Provide a rules file]:RULES:_default' \
'--rules=[Provide a rules file]:RULES:_default' \
'-o+[Write to output file]:OUTPUT:_default' \
'--output=[Write to output file]:OUTPUT:_default' \
'-p[Print output in JSON format. Use -p as the short flag]' \
'--print-json[Print output in JSON format. Use -p as the short flag]' \
'-y[Print output in YAML format]' \
'--print-yaml[Print output in YAML format]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(rulegen)
_arguments "${_arguments_options[@]}" : \
'-o+[Write to output file]:OUTPUT:_default' \
'--output=[Write to output file]:OUTPUT:_default' \
'-t+[Provide path to a CloudFormation template file in JSON or YAML]:TEMPLATE:_default' \
'--template=[Provide path to a CloudFormation template file in JSON or YAML]:TEMPLATE:_default' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-s+[]:SHELL:(bash zsh fish)' \
'--shell=[]:SHELL:(bash zsh fish)' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_cfn-guard__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:cfn-guard-help-command-$line[1]:"
        case $line[1] in
            (validate)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(parse-tree)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(rulegen)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_cfn-guard_commands] )) ||
_cfn-guard_commands() {
    local commands; commands=(
'validate:Evaluates rules against the data files to determine success or failure. You can point rules flag to a rules directory and point data flag to a data directory. When pointed to a directory it will read all rules in the directory file and evaluate them against the data files found in the directory. The command can also point to a single file and it would work as well. Note - When pointing the command to a directory, the directory may not contain a mix of rules and data files. The directory being pointed to must contain only data files, or rules files. ' \
'test:Built in unit testing capability to validate a Guard rules file against unit tests specified in YAML format to determine each individual rule'\''s success or failure testing. ' \
'parse-tree:Prints out the parse tree for the rules defined in the file.' \
'rulegen:Autogenerate rules from an existing JSON- or YAML- formatted data. (Currently works with only CloudFormation templates)' \
'completions:Generate auto-completions for all the sub-commands in shell.' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'cfn-guard commands' commands "$@"
}
(( $+functions[_cfn-guard__completions_commands] )) ||
_cfn-guard__completions_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard completions commands' commands "$@"
}
(( $+functions[_cfn-guard__help_commands] )) ||
_cfn-guard__help_commands() {
    local commands; commands=(
'validate:Evaluates rules against the data files to determine success or failure. You can point rules flag to a rules directory and point data flag to a data directory. When pointed to a directory it will read all rules in the directory file and evaluate them against the data files found in the directory. The command can also point to a single file and it would work as well. Note - When pointing the command to a directory, the directory may not contain a mix of rules and data files. The directory being pointed to must contain only data files, or rules files. ' \
'test:Built in unit testing capability to validate a Guard rules file against unit tests specified in YAML format to determine each individual rule'\''s success or failure testing. ' \
'parse-tree:Prints out the parse tree for the rules defined in the file.' \
'rulegen:Autogenerate rules from an existing JSON- or YAML- formatted data. (Currently works with only CloudFormation templates)' \
'completions:Generate auto-completions for all the sub-commands in shell.' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'cfn-guard help commands' commands "$@"
}
(( $+functions[_cfn-guard__help__completions_commands] )) ||
_cfn-guard__help__completions_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard help completions commands' commands "$@"
}
(( $+functions[_cfn-guard__help__help_commands] )) ||
_cfn-guard__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard help help commands' commands "$@"
}
(( $+functions[_cfn-guard__help__parse-tree_commands] )) ||
_cfn-guard__help__parse-tree_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard help parse-tree commands' commands "$@"
}
(( $+functions[_cfn-guard__help__rulegen_commands] )) ||
_cfn-guard__help__rulegen_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard help rulegen commands' commands "$@"
}
(( $+functions[_cfn-guard__help__test_commands] )) ||
_cfn-guard__help__test_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard help test commands' commands "$@"
}
(( $+functions[_cfn-guard__help__validate_commands] )) ||
_cfn-guard__help__validate_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard help validate commands' commands "$@"
}
(( $+functions[_cfn-guard__parse-tree_commands] )) ||
_cfn-guard__parse-tree_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard parse-tree commands' commands "$@"
}
(( $+functions[_cfn-guard__rulegen_commands] )) ||
_cfn-guard__rulegen_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard rulegen commands' commands "$@"
}
(( $+functions[_cfn-guard__test_commands] )) ||
_cfn-guard__test_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard test commands' commands "$@"
}
(( $+functions[_cfn-guard__validate_commands] )) ||
_cfn-guard__validate_commands() {
    local commands; commands=()
    _describe -t commands 'cfn-guard validate commands' commands "$@"
}

if [ "$funcstack[1]" = "_cfn-guard" ]; then
    _cfn-guard "$@"
else
    compdef _cfn-guard cfn-guard
fi
