#!/usr/bin/env zsh
# Command completion for pkl
# Generated by Clikt

autoload -Uz compinit
compinit
autoload -Uz bashcompinit
bashcompinit

__skip_opt_eq() {
    # this takes advantage of the fact that bash functions can write to local
    # variables in their callers
    (( i = i + 1 ))
    if [[ "${COMP_WORDS[$i]}" == '=' ]]; then
          (( i = i + 1 ))
    fi
}

__complete_files() {
   # Generate filename completions
   local word="$1"
   local IFS=$'\n'

   # quote each completion to support spaces and special characters
   COMPREPLY=($(compgen -o filenames -f -- "$word" | while read -r line; do
       printf "%q\n" "$line"
   done))
}

_pkl() {
  local i=1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name=''
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        -v|--version)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      eval)
        _pkl_eval $(( i + 1 ))
        return
        ;;
      repl)
        _pkl_repl $(( i + 1 ))
        return
        ;;
      server)
        _pkl_server $(( i + 1 ))
        return
        ;;
      test)
        _pkl_test $(( i + 1 ))
        return
        ;;
      project)
        _pkl_project $(( i + 1 ))
        return
        ;;
      download-package)
        _pkl_download_package $(( i + 1 ))
        return
        ;;
      analyze)
        _pkl_analyze $(( i + 1 ))
        return
        ;;
      format)
        _pkl_format $(( i + 1 ))
        return
        ;;
      run)
        _pkl_run $(( i + 1 ))
        return
        ;;
      shell-completion)
        _pkl_shell_completion $(( i + 1 ))
        return
        ;;
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '-v --version -h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--version")
      ;;
    "--help")
      ;;
    *)
      COMPREPLY=($(compgen -W 'eval repl server test project download-package analyze format run shell-completion' -- "${word}"))
      ;;
  esac
}

_pkl_eval() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name='modules'
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        --allowed-modules)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-modules' || in_param=''
          continue
          ;;
        --allowed-resources)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-resources' || in_param=''
          continue
          ;;
        --root-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--root-dir' || in_param=''
          continue
          ;;
        --cache-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--cache-dir' || in_param=''
          continue
          ;;
        -w|--working-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--working-dir' || in_param=''
          continue
          ;;
        -p|--property)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--property' || in_param=''
          continue
          ;;
        --color)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--color' || in_param=''
          continue
          ;;
        --no-cache)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -f|--format)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--format' || in_param=''
          continue
          ;;
        -e|--env-var)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--env-var' || in_param=''
          continue
          ;;
        --module-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--module-path' || in_param=''
          continue
          ;;
        --settings)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--settings' || in_param=''
          continue
          ;;
        -t|--timeout)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--timeout' || in_param=''
          continue
          ;;
        --ca-certificates)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--ca-certificates' || in_param=''
          continue
          ;;
        --http-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-proxy' || in_param=''
          continue
          ;;
        --http-no-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-no-proxy' || in_param=''
          continue
          ;;
        --http-rewrite)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-rewrite' || in_param=''
          continue
          ;;
        --external-module-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-module-reader' || in_param=''
          continue
          ;;
        --external-resource-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-resource-reader' || in_param=''
          continue
          ;;
        --trace-mode)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--trace-mode' || in_param=''
          continue
          ;;
        --project-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--project-dir' || in_param=''
          continue
          ;;
        --omit-project-settings)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --no-project)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -o|--output-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--output-path' || in_param=''
          continue
          ;;
        --module-output-separator)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--module-output-separator' || in_param=''
          continue
          ;;
        -x|--expression)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--expression' || in_param=''
          continue
          ;;
        -m|--multiple-file-output-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--multiple-file-output-path' || in_param=''
          continue
          ;;
        --power-assertions|--no-power-assertions)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '--allowed-modules --allowed-resources --root-dir --cache-dir -w --working-dir -p --property --color --no-cache -f --format -e --env-var --module-path --settings -t --timeout --ca-certificates --http-proxy --http-no-proxy --http-rewrite --external-module-reader --external-resource-reader --trace-mode --project-dir --omit-project-settings --no-project -o --output-path --module-output-separator -x --expression -m --multiple-file-output-path --power-assertions --no-power-assertions -h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--allowed-modules")
      ;;
    "--allowed-resources")
      ;;
    "--root-dir")
       __complete_files "${word}"
      ;;
    "--cache-dir")
       __complete_files "${word}"
      ;;
    "--working-dir")
       __complete_files "${word}"
      ;;
    "--property")
      ;;
    "--color")
      COMPREPLY=($(compgen -W 'never auto always' -- "${word}"))
      ;;
    "--no-cache")
      ;;
    "--format")
      COMPREPLY=($(compgen -W 'json jsonnet pcf properties plist textproto xml yaml pkl-binary' -- "${word}"))
      ;;
    "--env-var")
      ;;
    "--module-path")
       __complete_files "${word}"
      ;;
    "--settings")
       __complete_files "${word}"
      ;;
    "--timeout")
      ;;
    "--ca-certificates")
       __complete_files "${word}"
      ;;
    "--http-proxy")
      ;;
    "--http-no-proxy")
      ;;
    "--http-rewrite")
      ;;
    "--external-module-reader")
      ;;
    "--external-resource-reader")
      ;;
    "--trace-mode")
      COMPREPLY=($(compgen -W 'compact pretty' -- "${word}"))
      ;;
    "--project-dir")
       __complete_files "${word}"
      ;;
    "--omit-project-settings")
      ;;
    "--no-project")
      ;;
    "--output-path")
       __complete_files "${word}"
      ;;
    "--module-output-separator")
      ;;
    "--expression")
      ;;
    "--multiple-file-output-path")
       __complete_files "${word}"
      ;;
    "--no-power-assertions")
      ;;
    "--help")
      ;;
    "modules")
       __complete_files "${word}"
      ;;
  esac
}

_pkl_repl() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name=''
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        --allowed-modules)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-modules' || in_param=''
          continue
          ;;
        --allowed-resources)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-resources' || in_param=''
          continue
          ;;
        --root-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--root-dir' || in_param=''
          continue
          ;;
        --cache-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--cache-dir' || in_param=''
          continue
          ;;
        -w|--working-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--working-dir' || in_param=''
          continue
          ;;
        -p|--property)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--property' || in_param=''
          continue
          ;;
        --color)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--color' || in_param=''
          continue
          ;;
        --no-cache)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -f|--format)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--format' || in_param=''
          continue
          ;;
        -e|--env-var)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--env-var' || in_param=''
          continue
          ;;
        --module-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--module-path' || in_param=''
          continue
          ;;
        --settings)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--settings' || in_param=''
          continue
          ;;
        -t|--timeout)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--timeout' || in_param=''
          continue
          ;;
        --ca-certificates)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--ca-certificates' || in_param=''
          continue
          ;;
        --http-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-proxy' || in_param=''
          continue
          ;;
        --http-no-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-no-proxy' || in_param=''
          continue
          ;;
        --http-rewrite)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-rewrite' || in_param=''
          continue
          ;;
        --external-module-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-module-reader' || in_param=''
          continue
          ;;
        --external-resource-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-resource-reader' || in_param=''
          continue
          ;;
        --trace-mode)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--trace-mode' || in_param=''
          continue
          ;;
        --project-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--project-dir' || in_param=''
          continue
          ;;
        --omit-project-settings)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --no-project)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '--allowed-modules --allowed-resources --root-dir --cache-dir -w --working-dir -p --property --color --no-cache -f --format -e --env-var --module-path --settings -t --timeout --ca-certificates --http-proxy --http-no-proxy --http-rewrite --external-module-reader --external-resource-reader --trace-mode --project-dir --omit-project-settings --no-project -h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--allowed-modules")
      ;;
    "--allowed-resources")
      ;;
    "--root-dir")
       __complete_files "${word}"
      ;;
    "--cache-dir")
       __complete_files "${word}"
      ;;
    "--working-dir")
       __complete_files "${word}"
      ;;
    "--property")
      ;;
    "--color")
      COMPREPLY=($(compgen -W 'never auto always' -- "${word}"))
      ;;
    "--no-cache")
      ;;
    "--format")
      COMPREPLY=($(compgen -W 'json jsonnet pcf properties plist textproto xml yaml pkl-binary' -- "${word}"))
      ;;
    "--env-var")
      ;;
    "--module-path")
       __complete_files "${word}"
      ;;
    "--settings")
       __complete_files "${word}"
      ;;
    "--timeout")
      ;;
    "--ca-certificates")
       __complete_files "${word}"
      ;;
    "--http-proxy")
      ;;
    "--http-no-proxy")
      ;;
    "--http-rewrite")
      ;;
    "--external-module-reader")
      ;;
    "--external-resource-reader")
      ;;
    "--trace-mode")
      COMPREPLY=($(compgen -W 'compact pretty' -- "${word}"))
      ;;
    "--project-dir")
       __complete_files "${word}"
      ;;
    "--omit-project-settings")
      ;;
    "--no-project")
      ;;
    "--help")
      ;;
  esac
}

_pkl_server() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name=''
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '-h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--help")
      ;;
  esac
}

_pkl_test() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name='modules'
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        --allowed-modules)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-modules' || in_param=''
          continue
          ;;
        --allowed-resources)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-resources' || in_param=''
          continue
          ;;
        --root-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--root-dir' || in_param=''
          continue
          ;;
        --cache-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--cache-dir' || in_param=''
          continue
          ;;
        -w|--working-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--working-dir' || in_param=''
          continue
          ;;
        -p|--property)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--property' || in_param=''
          continue
          ;;
        --color)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--color' || in_param=''
          continue
          ;;
        --no-cache)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -f|--format)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--format' || in_param=''
          continue
          ;;
        -e|--env-var)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--env-var' || in_param=''
          continue
          ;;
        --module-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--module-path' || in_param=''
          continue
          ;;
        --settings)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--settings' || in_param=''
          continue
          ;;
        -t|--timeout)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--timeout' || in_param=''
          continue
          ;;
        --ca-certificates)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--ca-certificates' || in_param=''
          continue
          ;;
        --http-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-proxy' || in_param=''
          continue
          ;;
        --http-no-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-no-proxy' || in_param=''
          continue
          ;;
        --http-rewrite)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-rewrite' || in_param=''
          continue
          ;;
        --external-module-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-module-reader' || in_param=''
          continue
          ;;
        --external-resource-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-resource-reader' || in_param=''
          continue
          ;;
        --trace-mode)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--trace-mode' || in_param=''
          continue
          ;;
        --project-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--project-dir' || in_param=''
          continue
          ;;
        --omit-project-settings)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --no-project)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --junit-reports)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--junit-reports' || in_param=''
          continue
          ;;
        --junit-aggregate-reports)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --junit-aggregate-suite-name)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--junit-aggregate-suite-name' || in_param=''
          continue
          ;;
        --overwrite)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --power-assertions|--no-power-assertions)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '--allowed-modules --allowed-resources --root-dir --cache-dir -w --working-dir -p --property --color --no-cache -f --format -e --env-var --module-path --settings -t --timeout --ca-certificates --http-proxy --http-no-proxy --http-rewrite --external-module-reader --external-resource-reader --trace-mode --project-dir --omit-project-settings --no-project --junit-reports --junit-aggregate-reports --junit-aggregate-suite-name --overwrite --power-assertions --no-power-assertions -h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--allowed-modules")
      ;;
    "--allowed-resources")
      ;;
    "--root-dir")
       __complete_files "${word}"
      ;;
    "--cache-dir")
       __complete_files "${word}"
      ;;
    "--working-dir")
       __complete_files "${word}"
      ;;
    "--property")
      ;;
    "--color")
      COMPREPLY=($(compgen -W 'never auto always' -- "${word}"))
      ;;
    "--no-cache")
      ;;
    "--format")
      COMPREPLY=($(compgen -W 'json jsonnet pcf properties plist textproto xml yaml pkl-binary' -- "${word}"))
      ;;
    "--env-var")
      ;;
    "--module-path")
       __complete_files "${word}"
      ;;
    "--settings")
       __complete_files "${word}"
      ;;
    "--timeout")
      ;;
    "--ca-certificates")
       __complete_files "${word}"
      ;;
    "--http-proxy")
      ;;
    "--http-no-proxy")
      ;;
    "--http-rewrite")
      ;;
    "--external-module-reader")
      ;;
    "--external-resource-reader")
      ;;
    "--trace-mode")
      COMPREPLY=($(compgen -W 'compact pretty' -- "${word}"))
      ;;
    "--project-dir")
       __complete_files "${word}"
      ;;
    "--omit-project-settings")
      ;;
    "--no-project")
      ;;
    "--junit-reports")
       __complete_files "${word}"
      ;;
    "--junit-aggregate-reports")
      ;;
    "--junit-aggregate-suite-name")
      ;;
    "--overwrite")
      ;;
    "--no-power-assertions")
      ;;
    "--help")
      ;;
    "modules")
       __complete_files "${word}"
      ;;
  esac
}

_pkl_project() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name=''
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      resolve)
        _pkl_project_resolve $(( i + 1 ))
        return
        ;;
      package)
        _pkl_project_package $(( i + 1 ))
        return
        ;;
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '-h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--help")
      ;;
    *)
      COMPREPLY=($(compgen -W 'resolve package' -- "${word}"))
      ;;
  esac
}

_pkl_project_resolve() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name='dir'
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        --allowed-modules)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-modules' || in_param=''
          continue
          ;;
        --allowed-resources)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-resources' || in_param=''
          continue
          ;;
        --root-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--root-dir' || in_param=''
          continue
          ;;
        --cache-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--cache-dir' || in_param=''
          continue
          ;;
        -w|--working-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--working-dir' || in_param=''
          continue
          ;;
        -p|--property)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--property' || in_param=''
          continue
          ;;
        --color)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--color' || in_param=''
          continue
          ;;
        --no-cache)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -f|--format)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--format' || in_param=''
          continue
          ;;
        -e|--env-var)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--env-var' || in_param=''
          continue
          ;;
        --module-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--module-path' || in_param=''
          continue
          ;;
        --settings)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--settings' || in_param=''
          continue
          ;;
        -t|--timeout)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--timeout' || in_param=''
          continue
          ;;
        --ca-certificates)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--ca-certificates' || in_param=''
          continue
          ;;
        --http-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-proxy' || in_param=''
          continue
          ;;
        --http-no-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-no-proxy' || in_param=''
          continue
          ;;
        --http-rewrite)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-rewrite' || in_param=''
          continue
          ;;
        --external-module-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-module-reader' || in_param=''
          continue
          ;;
        --external-resource-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-resource-reader' || in_param=''
          continue
          ;;
        --trace-mode)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--trace-mode' || in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '--allowed-modules --allowed-resources --root-dir --cache-dir -w --working-dir -p --property --color --no-cache -f --format -e --env-var --module-path --settings -t --timeout --ca-certificates --http-proxy --http-no-proxy --http-rewrite --external-module-reader --external-resource-reader --trace-mode -h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--allowed-modules")
      ;;
    "--allowed-resources")
      ;;
    "--root-dir")
       __complete_files "${word}"
      ;;
    "--cache-dir")
       __complete_files "${word}"
      ;;
    "--working-dir")
       __complete_files "${word}"
      ;;
    "--property")
      ;;
    "--color")
      COMPREPLY=($(compgen -W 'never auto always' -- "${word}"))
      ;;
    "--no-cache")
      ;;
    "--format")
      COMPREPLY=($(compgen -W 'json jsonnet pcf properties plist textproto xml yaml pkl-binary' -- "${word}"))
      ;;
    "--env-var")
      ;;
    "--module-path")
       __complete_files "${word}"
      ;;
    "--settings")
       __complete_files "${word}"
      ;;
    "--timeout")
      ;;
    "--ca-certificates")
       __complete_files "${word}"
      ;;
    "--http-proxy")
      ;;
    "--http-no-proxy")
      ;;
    "--http-rewrite")
      ;;
    "--external-module-reader")
      ;;
    "--external-resource-reader")
      ;;
    "--trace-mode")
      COMPREPLY=($(compgen -W 'compact pretty' -- "${word}"))
      ;;
    "--help")
      ;;
    "dir")
       __complete_files "${word}"
      ;;
  esac
}

_pkl_project_package() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name='dir'
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        --allowed-modules)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-modules' || in_param=''
          continue
          ;;
        --allowed-resources)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-resources' || in_param=''
          continue
          ;;
        --root-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--root-dir' || in_param=''
          continue
          ;;
        --cache-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--cache-dir' || in_param=''
          continue
          ;;
        -w|--working-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--working-dir' || in_param=''
          continue
          ;;
        -p|--property)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--property' || in_param=''
          continue
          ;;
        --color)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--color' || in_param=''
          continue
          ;;
        --no-cache)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -f|--format)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--format' || in_param=''
          continue
          ;;
        -e|--env-var)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--env-var' || in_param=''
          continue
          ;;
        --module-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--module-path' || in_param=''
          continue
          ;;
        --settings)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--settings' || in_param=''
          continue
          ;;
        -t|--timeout)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--timeout' || in_param=''
          continue
          ;;
        --ca-certificates)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--ca-certificates' || in_param=''
          continue
          ;;
        --http-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-proxy' || in_param=''
          continue
          ;;
        --http-no-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-no-proxy' || in_param=''
          continue
          ;;
        --http-rewrite)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-rewrite' || in_param=''
          continue
          ;;
        --external-module-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-module-reader' || in_param=''
          continue
          ;;
        --external-resource-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-resource-reader' || in_param=''
          continue
          ;;
        --trace-mode)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--trace-mode' || in_param=''
          continue
          ;;
        --junit-reports)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--junit-reports' || in_param=''
          continue
          ;;
        --junit-aggregate-reports)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --junit-aggregate-suite-name)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--junit-aggregate-suite-name' || in_param=''
          continue
          ;;
        --overwrite)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --output-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--output-path' || in_param=''
          continue
          ;;
        --skip-publish-check)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '--allowed-modules --allowed-resources --root-dir --cache-dir -w --working-dir -p --property --color --no-cache -f --format -e --env-var --module-path --settings -t --timeout --ca-certificates --http-proxy --http-no-proxy --http-rewrite --external-module-reader --external-resource-reader --trace-mode --junit-reports --junit-aggregate-reports --junit-aggregate-suite-name --overwrite --output-path --skip-publish-check -h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--allowed-modules")
      ;;
    "--allowed-resources")
      ;;
    "--root-dir")
       __complete_files "${word}"
      ;;
    "--cache-dir")
       __complete_files "${word}"
      ;;
    "--working-dir")
       __complete_files "${word}"
      ;;
    "--property")
      ;;
    "--color")
      COMPREPLY=($(compgen -W 'never auto always' -- "${word}"))
      ;;
    "--no-cache")
      ;;
    "--format")
      COMPREPLY=($(compgen -W 'json jsonnet pcf properties plist textproto xml yaml pkl-binary' -- "${word}"))
      ;;
    "--env-var")
      ;;
    "--module-path")
       __complete_files "${word}"
      ;;
    "--settings")
       __complete_files "${word}"
      ;;
    "--timeout")
      ;;
    "--ca-certificates")
       __complete_files "${word}"
      ;;
    "--http-proxy")
      ;;
    "--http-no-proxy")
      ;;
    "--http-rewrite")
      ;;
    "--external-module-reader")
      ;;
    "--external-resource-reader")
      ;;
    "--trace-mode")
      COMPREPLY=($(compgen -W 'compact pretty' -- "${word}"))
      ;;
    "--junit-reports")
       __complete_files "${word}"
      ;;
    "--junit-aggregate-reports")
      ;;
    "--junit-aggregate-suite-name")
      ;;
    "--overwrite")
      ;;
    "--output-path")
       __complete_files "${word}"
      ;;
    "--skip-publish-check")
      ;;
    "--help")
      ;;
    "dir")
       __complete_files "${word}"
      ;;
  esac
}

_pkl_download_package() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name='package'
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        --allowed-modules)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-modules' || in_param=''
          continue
          ;;
        --allowed-resources)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-resources' || in_param=''
          continue
          ;;
        --root-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--root-dir' || in_param=''
          continue
          ;;
        --cache-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--cache-dir' || in_param=''
          continue
          ;;
        -w|--working-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--working-dir' || in_param=''
          continue
          ;;
        -p|--property)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--property' || in_param=''
          continue
          ;;
        --color)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--color' || in_param=''
          continue
          ;;
        --no-cache)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -f|--format)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--format' || in_param=''
          continue
          ;;
        -e|--env-var)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--env-var' || in_param=''
          continue
          ;;
        --module-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--module-path' || in_param=''
          continue
          ;;
        --settings)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--settings' || in_param=''
          continue
          ;;
        -t|--timeout)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--timeout' || in_param=''
          continue
          ;;
        --ca-certificates)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--ca-certificates' || in_param=''
          continue
          ;;
        --http-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-proxy' || in_param=''
          continue
          ;;
        --http-no-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-no-proxy' || in_param=''
          continue
          ;;
        --http-rewrite)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-rewrite' || in_param=''
          continue
          ;;
        --external-module-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-module-reader' || in_param=''
          continue
          ;;
        --external-resource-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-resource-reader' || in_param=''
          continue
          ;;
        --trace-mode)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--trace-mode' || in_param=''
          continue
          ;;
        --project-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--project-dir' || in_param=''
          continue
          ;;
        --omit-project-settings)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --no-project)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --no-transitive)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '--allowed-modules --allowed-resources --root-dir --cache-dir -w --working-dir -p --property --color --no-cache -f --format -e --env-var --module-path --settings -t --timeout --ca-certificates --http-proxy --http-no-proxy --http-rewrite --external-module-reader --external-resource-reader --trace-mode --project-dir --omit-project-settings --no-project --no-transitive -h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--allowed-modules")
      ;;
    "--allowed-resources")
      ;;
    "--root-dir")
       __complete_files "${word}"
      ;;
    "--cache-dir")
       __complete_files "${word}"
      ;;
    "--working-dir")
       __complete_files "${word}"
      ;;
    "--property")
      ;;
    "--color")
      COMPREPLY=($(compgen -W 'never auto always' -- "${word}"))
      ;;
    "--no-cache")
      ;;
    "--format")
      COMPREPLY=($(compgen -W 'json jsonnet pcf properties plist textproto xml yaml pkl-binary' -- "${word}"))
      ;;
    "--env-var")
      ;;
    "--module-path")
       __complete_files "${word}"
      ;;
    "--settings")
       __complete_files "${word}"
      ;;
    "--timeout")
      ;;
    "--ca-certificates")
       __complete_files "${word}"
      ;;
    "--http-proxy")
      ;;
    "--http-no-proxy")
      ;;
    "--http-rewrite")
      ;;
    "--external-module-reader")
      ;;
    "--external-resource-reader")
      ;;
    "--trace-mode")
      COMPREPLY=($(compgen -W 'compact pretty' -- "${word}"))
      ;;
    "--project-dir")
       __complete_files "${word}"
      ;;
    "--omit-project-settings")
      ;;
    "--no-project")
      ;;
    "--no-transitive")
      ;;
    "--help")
      ;;
    "package")
      ;;
  esac
}

_pkl_analyze() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name=''
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      imports)
        _pkl_analyze_imports $(( i + 1 ))
        return
        ;;
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '-h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--help")
      ;;
    *)
      COMPREPLY=($(compgen -W 'imports' -- "${word}"))
      ;;
  esac
}

_pkl_analyze_imports() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name='modules'
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        --allowed-modules)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-modules' || in_param=''
          continue
          ;;
        --allowed-resources)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-resources' || in_param=''
          continue
          ;;
        --root-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--root-dir' || in_param=''
          continue
          ;;
        --cache-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--cache-dir' || in_param=''
          continue
          ;;
        -w|--working-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--working-dir' || in_param=''
          continue
          ;;
        -p|--property)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--property' || in_param=''
          continue
          ;;
        --color)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--color' || in_param=''
          continue
          ;;
        --no-cache)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -f|--format)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--format' || in_param=''
          continue
          ;;
        -e|--env-var)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--env-var' || in_param=''
          continue
          ;;
        --module-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--module-path' || in_param=''
          continue
          ;;
        --settings)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--settings' || in_param=''
          continue
          ;;
        -t|--timeout)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--timeout' || in_param=''
          continue
          ;;
        --ca-certificates)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--ca-certificates' || in_param=''
          continue
          ;;
        --http-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-proxy' || in_param=''
          continue
          ;;
        --http-no-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-no-proxy' || in_param=''
          continue
          ;;
        --http-rewrite)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-rewrite' || in_param=''
          continue
          ;;
        --external-module-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-module-reader' || in_param=''
          continue
          ;;
        --external-resource-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-resource-reader' || in_param=''
          continue
          ;;
        --trace-mode)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--trace-mode' || in_param=''
          continue
          ;;
        --project-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--project-dir' || in_param=''
          continue
          ;;
        --omit-project-settings)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --no-project)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -o|--output-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--output-path' || in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '--allowed-modules --allowed-resources --root-dir --cache-dir -w --working-dir -p --property --color --no-cache -f --format -e --env-var --module-path --settings -t --timeout --ca-certificates --http-proxy --http-no-proxy --http-rewrite --external-module-reader --external-resource-reader --trace-mode --project-dir --omit-project-settings --no-project -o --output-path -h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--allowed-modules")
      ;;
    "--allowed-resources")
      ;;
    "--root-dir")
       __complete_files "${word}"
      ;;
    "--cache-dir")
       __complete_files "${word}"
      ;;
    "--working-dir")
       __complete_files "${word}"
      ;;
    "--property")
      ;;
    "--color")
      COMPREPLY=($(compgen -W 'never auto always' -- "${word}"))
      ;;
    "--no-cache")
      ;;
    "--format")
      COMPREPLY=($(compgen -W 'json jsonnet pcf properties plist textproto xml yaml pkl-binary' -- "${word}"))
      ;;
    "--env-var")
      ;;
    "--module-path")
       __complete_files "${word}"
      ;;
    "--settings")
       __complete_files "${word}"
      ;;
    "--timeout")
      ;;
    "--ca-certificates")
       __complete_files "${word}"
      ;;
    "--http-proxy")
      ;;
    "--http-no-proxy")
      ;;
    "--http-rewrite")
      ;;
    "--external-module-reader")
      ;;
    "--external-resource-reader")
      ;;
    "--trace-mode")
      COMPREPLY=($(compgen -W 'compact pretty' -- "${word}"))
      ;;
    "--project-dir")
       __complete_files "${word}"
      ;;
    "--omit-project-settings")
      ;;
    "--no-project")
      ;;
    "--output-path")
       __complete_files "${word}"
      ;;
    "--help")
      ;;
    "modules")
       __complete_files "${word}"
      ;;
  esac
}

_pkl_format() {
  local i=$1
  local in_param=''
  local fixed_arg_names=()
  local vararg_name='paths'
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        --grammar-version)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--grammar-version' || in_param=''
          continue
          ;;
        -w|--write)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --diff-name-only)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -s|--silent)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '--grammar-version -w --write --diff-name-only -s --silent -h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--grammar-version")
      COMPREPLY=($(compgen -W '1 2' -- "${word}"))
      ;;
    "--write")
      ;;
    "--diff-name-only")
      ;;
    "--silent")
      ;;
    "--help")
      ;;
    "paths")
       __complete_files "${word}"
      ;;
  esac
}

_pkl_run() {
  local i=$1
  local in_param=''
  local fixed_arg_names=('module')
  local vararg_name='args'
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        --allowed-modules)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-modules' || in_param=''
          continue
          ;;
        --allowed-resources)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--allowed-resources' || in_param=''
          continue
          ;;
        --root-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--root-dir' || in_param=''
          continue
          ;;
        --cache-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--cache-dir' || in_param=''
          continue
          ;;
        -w|--working-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--working-dir' || in_param=''
          continue
          ;;
        -p|--property)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--property' || in_param=''
          continue
          ;;
        --color)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--color' || in_param=''
          continue
          ;;
        --no-cache)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        -f|--format)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--format' || in_param=''
          continue
          ;;
        -e|--env-var)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--env-var' || in_param=''
          continue
          ;;
        --module-path)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--module-path' || in_param=''
          continue
          ;;
        --settings)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--settings' || in_param=''
          continue
          ;;
        -t|--timeout)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--timeout' || in_param=''
          continue
          ;;
        --ca-certificates)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--ca-certificates' || in_param=''
          continue
          ;;
        --http-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-proxy' || in_param=''
          continue
          ;;
        --http-no-proxy)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-no-proxy' || in_param=''
          continue
          ;;
        --http-rewrite)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--http-rewrite' || in_param=''
          continue
          ;;
        --external-module-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-module-reader' || in_param=''
          continue
          ;;
        --external-resource-reader)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--external-resource-reader' || in_param=''
          continue
          ;;
        --trace-mode)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--trace-mode' || in_param=''
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --project-dir)
          __skip_opt_eq
          (( i = i + 1 ))
          [[ ${i} -gt COMP_CWORD ]] && in_param='--project-dir' || in_param=''
          continue
          ;;
        --omit-project-settings)
          __skip_opt_eq
          in_param=''
          continue
          ;;
        --no-project)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '--allowed-modules --allowed-resources --root-dir --cache-dir -w --working-dir -p --property --color --no-cache -f --format -e --env-var --module-path --settings -t --timeout --ca-certificates --http-proxy --http-no-proxy --http-rewrite --external-module-reader --external-resource-reader --trace-mode -h --help --project-dir --omit-project-settings --no-project' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--allowed-modules")
      ;;
    "--allowed-resources")
      ;;
    "--root-dir")
       __complete_files "${word}"
      ;;
    "--cache-dir")
       __complete_files "${word}"
      ;;
    "--working-dir")
       __complete_files "${word}"
      ;;
    "--property")
      ;;
    "--color")
      COMPREPLY=($(compgen -W 'never auto always' -- "${word}"))
      ;;
    "--no-cache")
      ;;
    "--format")
      COMPREPLY=($(compgen -W 'json jsonnet pcf properties plist textproto xml yaml pkl-binary' -- "${word}"))
      ;;
    "--env-var")
      ;;
    "--module-path")
       __complete_files "${word}"
      ;;
    "--settings")
       __complete_files "${word}"
      ;;
    "--timeout")
      ;;
    "--ca-certificates")
       __complete_files "${word}"
      ;;
    "--http-proxy")
      ;;
    "--http-no-proxy")
      ;;
    "--http-rewrite")
      ;;
    "--external-module-reader")
      ;;
    "--external-resource-reader")
      ;;
    "--trace-mode")
      COMPREPLY=($(compgen -W 'compact pretty' -- "${word}"))
      ;;
    "--help")
      ;;
    "--project-dir")
       __complete_files "${word}"
      ;;
    "--omit-project-settings")
      ;;
    "--no-project")
      ;;
    "module")
       __complete_files "${word}"
      ;;
    "args")
      ;;
  esac
}

_pkl_shell_completion() {
  local i=$1
  local in_param=''
  local fixed_arg_names=('shell')
  local vararg_name=''
  local can_parse_options=1

  while [[ ${i} -lt $COMP_CWORD ]]; do
    if [[ ${can_parse_options} -eq 1 ]]; then
      case "${COMP_WORDS[$i]}" in
        --)
          can_parse_options=0
          (( i = i + 1 ));
          continue
          ;;
        -h|--help)
          __skip_opt_eq
          in_param=''
          continue
          ;;
      esac
    fi
    case "${COMP_WORDS[$i]}" in
      *)
        (( i = i + 1 ))
        # drop the head of the array
        fixed_arg_names=("${fixed_arg_names[@]:1}")
        ;;
    esac
  done
  local word="${COMP_WORDS[$COMP_CWORD]}"
  if [[ "${word}" =~ ^[-] ]]; then
    COMPREPLY=($(compgen -W '-h --help' -- "${word}"))
    return
  fi

  # We're either at an option's value, or the first remaining fixed size
  # arg, or the vararg if there are no fixed args left
  [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
  [[ -z "${in_param}" ]] && in_param=${vararg_name}

  case "${in_param}" in
    "--help")
      ;;
    "shell")
      COMPREPLY=($(compgen -W 'bash zsh fish' -- "${word}"))
      ;;
  esac
}

complete -F _pkl pkl
