# bash completion for experts
_experts_complete() {
  local cur prev
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev="${COMP_WORDS[COMP_CWORD-1]}"
  if [ "${COMP_CWORD}" -eq 1 ]; then
    COMPREPLY=( $(compgen -W "api config courses events login logout stats status update whoami --help --version" -- "$cur") )
    return
  fi
  case "${COMP_WORDS[1]}" in
    api)
      case "$prev" in
        --method|-X)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
        --field|-f)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
        --raw-field|-F)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
        --header|-H)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
        --input)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
      esac
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--method -X --field -f --raw-field -F --header -H --input --include -i --paginate --silent --help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
    config)
      case "$prev" in
        --api-url)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
      esac
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--api-url --json --help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
    courses)
      case "$prev" in
        --search)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
        --limit)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
        --page)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
      esac
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--search --limit --page --json --help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
    events)
      case "$prev" in
        --search)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
        --limit)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
        --page)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
      esac
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--search --limit --page --json --help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
    login)
      case "$prev" in
        --token)
          COMPREPLY=( $(compgen -W "" -- "$cur") )
          return
          ;;
      esac
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--token --browser --no-browser --help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
    logout)
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--yes -y --help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
    stats)
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
    status)
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--json --help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
    update)
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--check --help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
    whoami)
      if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "--json --help -h" -- "$cur") )
      else
        COMPREPLY=( $(compgen -W "" -- "$cur") )
      fi
      ;;
  esac
}
complete -F _experts_complete experts
