#compdef minijinja-cli

autoload -U is-at-least

_minijinja_cli() {
    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[@]}" : \
    '*--config-file=[Alternative path to the config file.]:PATH:_files' \
    '*-f+[The format of the input data]:FORMAT:((auto\:"detect from the file extension" cbor\:"CBOR (*.cbor)" ini\:"INI / Config (*.ini, *.conf, *.config, *.properties)" json\:"JSON / JSON5 (*.json, *.json5)" querystring\:"Query String / Form Encoded (*.qs)" toml\:"TOML (*.toml)" yaml\:"YAML 1.2 (*.yaml, *.yml)"))' \
    '*--format=[The format of the input data]:FORMAT:((auto\:"detect from the file extension" cbor\:"CBOR (*.cbor)" ini\:"INI / Config (*.ini, *.conf, *.config, *.properties)" json\:"JSON / JSON5 (*.json, *.json5)" querystring\:"Query String / Form Encoded (*.qs)" toml\:"TOML (*.toml)" yaml\:"YAML 1.2 (*.yaml, *.yml)"))' \
    '*-D+[Defines an input variable (key=value / key\:=json_value)]:EXPR:' \
    '*--define=[Defines an input variable (key=value / key\:=json_value)]:EXPR:' \
    '*-t+[Render a string template]:TEMPLATE_STRING:' \
    '*--template=[Render a string template]:TEMPLATE_STRING:' \
    '*-o+[Path to the output file]:FILENAME:_files' \
    '*--output=[Path to the output file]:FILENAME:_files' \
    '*--select=[Select a subset of the input data]:SELECTOR:' \
    '*--print-config[Print out the loaded config]' \
    '*-h[Print short help (short texts)]' \
    '*--help[Print short help (short texts)]' \
    '*--long-help[Print long help (extended, long explanation texts)]' \
    '*--syntax-help[Print syntax help (primer on Jinja2/MiniJinja syntax)]' \
    '*-V[Print version]' \
    '*--version[Print version]' \
    '*-a+[Reconfigures autoescape behavior]:MODE:(auto html json none)' \
    '*--autoescape=[Reconfigures autoescape behavior]:MODE:(auto html json none)' \
    '*--strict[Disallow undefined variables in templates]' \
    '*-n[Do not output a trailing newline]' \
    '*--no-newline[Do not output a trailing newline]' \
    '*--trim-blocks[Enable the trim-blocks flag]' \
    '*--lstrip-blocks[Enable the lstrip-blocks flag]' \
    '*--py-compat[Enables improved Python compatibility]' \
    '*-s+[Changes a syntax feature (feature=value) \[possible features\: block-start, block-end, variable-start, variable-end, comment-start, comment-end, line-statement-prefix, line-statement-comment\]]:PAIR:' \
    '*--syntax=[Changes a syntax feature (feature=value) \[possible features\: block-start, block-end, variable-start, variable-end, comment-start, comment-end, line-statement-prefix, line-statement-comment\]]:PAIR:' \
    '*--env[Pass environment variables as ENV to the template]' \
    '*--no-include[Disallow includes and extending]' \
    '*--safe-path=[Only allow includes from this path]:PATH:_files -/' \
    '*--fuel=[Configures the maximum fuel]:AMOUNT:' \
    '*-E+[Evaluates an template expression]:EXPR:' \
    '*--expr=[Evaluates an template expression]:EXPR:' \
    '*--expr-out=[The expression output mode]:MODE:(print json json-pretty status)' \
    '*--dump=[Dump internals of a template]:KIND:(instructions ast tokens)' \
    '*--repl[Starts the repl with the given data]' \
    '*--generate-completion=[Generate a completion script for the given shell]:SH:(bash elvish fish nushell powershell zsh)' \
    '::TEMPLATE_FILE -- Path to the input template:_files' \
    '*::DATA_FILE -- Path to one or more data files used as template context:_files' \
    && ret=0
    return ret
}

if [ "$funcstack[1]" = "_minijinja_cli" ]; then
    _minijinja_cli "$@"
else
    compdef _minijinja_cli minijinja-cli
fi
