_wflinfo() {

  local cur prev
  if _get_comp_words_by_ref -n= cur prev &>/dev/null; then
    case $prev in
      -p|--platform)
        COMPREPLY=($(compgen -W 'android cgl gbm glx surfaceless_egl sl wayland wgl x11_egl' -- "$cur"))
        return
        ;;
      -a|--api)
        COMPREPLY=($(compgen -W 'gl gles1 gles2 gles3' -- "$cur"))
        return
        ;;
      -V|--version)
        local versions=(1.{0..5} 2.{0..1} 3.{0..3} 4.{0..6})
        COMPREPLY=($(compgen -W "${versions[*]}" -- "$cur"))
        return
        ;;
      --profile)
        COMPREPLY=($(compgen -W 'core compat none' -- "$cur"))
        return
        ;;
      -f|--format)
        COMPREPLY=($(compgen -W 'original json' -- "$cur"))
        return
        ;;
    esac
  else
    cur="${COMP_WORDS[COMP_CWORD]}"
  fi

  local shortopts=(
    p
    a
    V
    v
    f
    h
  )

  local longopts=(
    platform
    api
    version
    profile
    verbose
    forward-compatible
    debug-context
    format
    help
  )

  if [[ "$cur" == "--"* ]]; then
    COMPREPLY=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}"))
  elif [[ "$cur" == "-"* && ${#cur} -gt 1 ]]; then
    COMPREPLY=($(compgen -P '-' -W '${shortopts[*]}' -- "${cur:1}"))
  else
    COMPREPLY=($(compgen -P '-' -W '${shortopts[*]}' -- "${cur:1}")
               $(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}"))
  fi
} &&
complete -F _wflinfo wflinfo
