#!/usr/bin/bash

function _pengwin_setup() { #  By convention, the function name
  local cur=${COMP_WORDS[COMP_CWORD]}
  local prev=${COMP_WORDS[COMP_CWORD - 1]}

  case "$prev" in
  EDITORS)
    mapfile -t COMPREPLY < <(compgen -W 'CODE EMACS NEOVIM' -- "${cur}")
    ;;
  GUI)
    mapfile -t COMPREPLY < <(compgen -W 'NLI GUILIB HIDPI STARTMENU TERMINAL SYNAPTIC VCXSRV WINTHEME X410' -- "${cur}")
    ;;
  TERMINAL)
    mapfile -t COMPREPLY < <(compgen -W 'WINTERM WSLTTY TILIX GTERM XFTERM TERMINATOR KONSO' -- "${cur}")
    ;;
  PROGRAMMING)
    mapfile -t COMPREPLY < <(compgen -W 'C++ DOTNET GO JAVA JOOMLA LATEX NIM NODEJS PYTHONPI RUBY RUST' -- "${cur}")
    ;;
  PYTHONPI)
    mapfile -t COMPREPLY < <(compgen -W 'PYENV PYTHONPIP POETRY' -- "${cur}")
    ;;
  SERVICES)
    mapfile -t COMPREPLY < <(compgen -W 'RCLOCAL SSH' -- "${cur}")
    ;;
  SETTINGS)
    mapfile -t COMPREPLY < <(compgen -W 'EXPLORER COLORTOOL LANGUAGE SHELLS' -- "${cur}")
    ;;
  SHELLS)
    mapfile -t COMPREPLY < <(compgen -W 'BASH-RL CSH FISH ZSH' -- "${cur}")
    ;;
  TOOLS)
    mapfile -t COMPREPLY < <(compgen -W 'HOMEBREW' -- "${cur}")
    ;;
  *)
    mapfile -t COMPREPLY < <(compgen -W "--debug -d --verbose -v -y --yes --assume-yes --noupdate --norebuildicons -q \
    --quiet --noninteractive update upgrade autoinstall install uninstall remove startmenu \
    EDITORS GUI MAINTENANCE PROGRAMMING SERVICES SETTINGS TOOLS UNINSTALL" -- "${cur}")
    ;;
  esac

  return 0
}

complete -F _pengwin_setup pengwin-setup
complete -F _pengwin_setup ./pengwin-setup
