_zrythm() {
  IFS='' read -r -d '' descriptions <<'EOF'
-h,--help: 'Show help options.'
--help-all: 'Show all help options.'
--help-gapplication: 'Show GApplication options . SS "Application Options:".'
-v,--version: 'Print version information.'
--gen-project: 'Generate a project from SCRIPT-FILE.'
--pretty: 'Print output in user-friendly way.'
-p,--print-settings: 'Print current settings.'
--reset-to-factory: 'Reset to factory settings.'
--audio-backend: 'Override the audio backend to use.'
--midi-backend: 'Override the MIDI backend to use.'
--dummy: 'Shorthand for --midi-backend=\,none\/ --audio-backend=\,none\/.'
--buf-size: 'Override the buffer size to use for the audio backend, if applicable.'
--samplerate: 'Override the samplerate to use for the audio backend, if applicable.'
-o,--output: 'File or directory to output to.'
--cyaml-log-level: 'Cyaml log level ENVIRONMENT.'

EOF

  COMPREPLY=()
  local cur
  cur=$(_get_cword)
  IFS='' read -r -d '' completions <<'EOF'
-h
--help
--help-all
--help-gapplication
-v
--version
--gen-project
--pretty
-p
--print-settings
--reset-to-factory
--audio-backend
--midi-backend
--dummy
--buf-size
--samplerate
-o
--output
--cyaml-log-level

EOF

  if [ -z "$cur" ]; then
      if declare -f _filedir &>/dev/null; then
          _filedir
      else
          COMPREPLY=( $(compgen -f -- "$cur") )
      fi
      return 0
  fi

  COMPREPLY=( $( compgen -W "$completions" -- "$cur" ) )
  if [[ ${#COMPREPLY[*]} -gt 1 ]]; then
      echo ""
      while read -r line; do
          [[ "$line" == "$cur"* ]] && echo "$line"
      done <<< "$descriptions"
  fi

  return 0
}
complete -F _zrythm zrythm
