#!/bin/bash

# Generated by airline BashCompletionGenerator

containsElement () {
  # This function from http://stackoverflow.com/a/8574392/107591
  local e
  for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
  return 1
}

function _complete_ontop_command_version() {
  # Get completion data
  COMPREPLY=()
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
  COMMANDS=$1

  FLAG_OPTS=""
  ARG_OPTS=""

  ARGUMENTS=
  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${ARGUMENTS}" -- ${CURR_WORD}) )
  echo ${COMPREPLY[@]}
  return 0
}

function _complete_ontop_command_help() {
  # Get completion data
  COMPREPLY=()
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
  COMMANDS=$1

  FLAG_OPTS=""
  ARG_OPTS=""

  ARGUMENTS=
  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${ARGUMENTS}" -- ${CURR_WORD}) )
  echo ${COMPREPLY[@]}
  return 0
}

function _complete_ontop_command_query() {
  # Get completion data
  COMPREPLY=()
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
  COMMANDS=$1

  FLAG_OPTS="--enable-annotations"
  ARG_OPTS="--facts-format --ontop-views --sparql-rules --xml-catalog -a --db-metadata -c --lenses -d --query -l -m -o -p -q --mapping -t --db-driver --properties -u -v --constraint --facts -x --db-password --db-url --db-user --ontology --facts-base-iri --output"

  $( containsElement ${PREV_WORD} ${ARG_OPTS[@]} )
  SAW_ARG=$?
  if [[ ${SAW_ARG} -eq 0 ]]; then
    ARG_VALUES=
    ARG_GENERATED_VALUES=
    case ${PREV_WORD} in
      -x|--xml-catalog)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --facts-format)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -l|--lenses|-v|--ontop-views)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -m|--mapping)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -c|--constraint)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-driver)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --sparql-rules)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-password)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -p|--properties)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-url)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --facts-base-iri)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -u|--db-user)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -a|--facts)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -t|--ontology)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -q|--query)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -o|--output)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -d|--db-metadata)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
    esac
  fi

  ARGUMENTS=
  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${ARGUMENTS}" -- ${CURR_WORD}) )
  echo ${COMPREPLY[@]}
  return 0
}

function _complete_ontop_command_materialize() {
  # Get completion data
  COMPREPLY=()
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
  COMMANDS=$1

  FLAG_OPTS="--enable-annotations --no-streaming --separate-files"
  ARG_OPTS="--facts-format --ontop-views --sparql-rules --xml-catalog -a --db-metadata -c --lenses -d -f --compression -l -m -o -p --mapping -t --db-driver --properties -u -v --constraint --facts -x --db-password --db-url --db-user --ontology --facts-base-iri --format --output"

  $( containsElement ${PREV_WORD} ${ARG_OPTS[@]} )
  SAW_ARG=$?
  if [[ ${SAW_ARG} -eq 0 ]]; then
    ARG_VALUES=
    ARG_GENERATED_VALUES=
    case ${PREV_WORD} in
      -x|--xml-catalog)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --facts-format)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -l|--lenses|-v|--ontop-views)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -m|--mapping)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -c|--constraint)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-driver)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --sparql-rules)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-password)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -p|--properties)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-url)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --facts-base-iri)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -u|--db-user)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -a|--facts)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -t|--ontology)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --compression)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -o|--output)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -f|--format)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -d|--db-metadata)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
    esac
  fi

  ARGUMENTS=
  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${ARGUMENTS}" -- ${CURR_WORD}) )
  echo ${COMPREPLY[@]}
  return 0
}

function _complete_ontop_command_bootstrap() {
  # Get completion data
  COMPREPLY=()
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
  COMMANDS=$1

  FLAG_OPTS=""
  ARG_OPTS="-m -p --mapping --base-iri -t -u --db-driver --properties --db-password --db-user --db-url --ontology -b"

  $( containsElement ${PREV_WORD} ${ARG_OPTS[@]} )
  SAW_ARG=$?
  if [[ ${SAW_ARG} -eq 0 ]]; then
    ARG_VALUES=
    ARG_GENERATED_VALUES=
    case ${PREV_WORD} in
      -u|--db-user)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -m|--mapping)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -t|--ontology)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-driver)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -b|--base-iri)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-password)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -p|--properties)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-url)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
    esac
  fi

  ARGUMENTS=
  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${ARGUMENTS}" -- ${CURR_WORD}) )
  echo ${COMPREPLY[@]}
  return 0
}

function _complete_ontop_command_validate() {
  # Get completion data
  COMPREPLY=()
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
  COMMANDS=$1

  FLAG_OPTS="--enable-annotations"
  ARG_OPTS="--facts-format --ontop-views --sparql-rules --xml-catalog -a --db-metadata -c --lenses -d -l -m -p --mapping -t --db-driver --properties -u -v --constraint --facts -x --db-password --db-url --db-user --ontology --facts-base-iri"

  $( containsElement ${PREV_WORD} ${ARG_OPTS[@]} )
  SAW_ARG=$?
  if [[ ${SAW_ARG} -eq 0 ]]; then
    ARG_VALUES=
    ARG_GENERATED_VALUES=
    case ${PREV_WORD} in
      -x|--xml-catalog)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --facts-format)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -l|--lenses|-v|--ontop-views)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -m|--mapping)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -c|--constraint)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-driver)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --sparql-rules)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-password)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -p|--properties)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-url)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --facts-base-iri)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -u|--db-user)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -a|--facts)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -t|--ontology)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -d|--db-metadata)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
    esac
  fi

  ARGUMENTS=
  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${ARGUMENTS}" -- ${CURR_WORD}) )
  echo ${COMPREPLY[@]}
  return 0
}

function _complete_ontop_command_endpoint() {
  # Get completion data
  COMPREPLY=()
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
  COMMANDS=$1

  FLAG_OPTS="--lazy --enable-download-ontology --dev --enable-annotations --disable-portal-page"
  ARG_OPTS="--facts-format --ontop-views --sparql-rules --xml-catalog -a --db-metadata -c --lenses -d --port --cors-allowed-origins --contexts --predefined-config -l -m -p --mapping -t --properties --db-driver -u -v --constraint --facts -x --db-password --db-url --db-user --ontology --facts-base-iri --portal --predefined-queries"

  $( containsElement ${PREV_WORD} ${ARG_OPTS[@]} )
  SAW_ARG=$?
  if [[ ${SAW_ARG} -eq 0 ]]; then
    ARG_VALUES=
    ARG_GENERATED_VALUES=
    case ${PREV_WORD} in
      --facts-format)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -l|--lenses|-v|--ontop-views)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -m|--mapping)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -c|--constraint)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --sparql-rules)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -p|--properties)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -t|--ontology)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --port)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --cors-allowed-origins)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --contexts)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --predefined-config)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -x|--xml-catalog)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-driver)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-password)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --db-url)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --facts-base-iri)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --portal)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      --predefined-queries)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -u|--db-user)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -a|--facts)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -d|--db-metadata)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
    esac
  fi

  ARGUMENTS=
  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${ARGUMENTS}" -- ${CURR_WORD}) )
  echo ${COMPREPLY[@]}
  return 0
}

function _complete_ontop_command_extractdbmetadata() {
  # Get completion data
  COMPREPLY=()
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
  COMMANDS=$1

  FLAG_OPTS=""
  ARG_OPTS="-o -p --properties --output"

  $( containsElement ${PREV_WORD} ${ARG_OPTS[@]} )
  SAW_ARG=$?
  if [[ ${SAW_ARG} -eq 0 ]]; then
    ARG_VALUES=
    ARG_GENERATED_VALUES=
    case ${PREV_WORD} in
      -p|--properties)
        COMPREPLY=( $(compgen -o default -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
      -o|--output)
        COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
        echo ${COMPREPLY[@]}
        return 0
        ;;
    esac
  fi

  ARGUMENTS=
  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${ARGUMENTS}" -- ${CURR_WORD}) )
  echo ${COMPREPLY[@]}
  return 0
}

function _complete_ontop() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
  CURR_CMD=
  if [[ ${COMP_CWORD} -ge 1 ]]; then
    CURR_CMD=${COMP_WORDS[1]}
  fi

  COMMANDS="help endpoint extract-db-metadata materialize query --version bootstrap validate"
  if [[ ${COMP_CWORD} -eq 1 ]]; then
    COMPREPLY=()
    COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${CURR_WORD}) )
    return 0
  fi

  case ${CURR_CMD} in 
    --version)
      COMPREPLY=( $(_complete_ontop_command_version "${COMMANDS}" ) )
      return $?
      ;;
    help)
      COMPREPLY=( $(_complete_ontop_command_help "${COMMANDS}" ) )
      return $?
      ;;
    query)
      COMPREPLY=( $(_complete_ontop_command_query "${COMMANDS}" ) )
      return $?
      ;;
    materialize)
      COMPREPLY=( $(_complete_ontop_command_materialize "${COMMANDS}" ) )
      return $?
      ;;
    bootstrap)
      COMPREPLY=( $(_complete_ontop_command_bootstrap "${COMMANDS}" ) )
      return $?
      ;;
    validate)
      COMPREPLY=( $(_complete_ontop_command_validate "${COMMANDS}" ) )
      return $?
      ;;
    endpoint)
      COMPREPLY=( $(_complete_ontop_command_endpoint "${COMMANDS}" ) )
      return $?
      ;;
    extract-db-metadata)
      COMPREPLY=( $(_complete_ontop_command_extractdbmetadata "${COMMANDS}" ) )
      return $?
      ;;
  esac

}

complete -F _complete_ontop ontop