_authstor_completions() {
  local cur prev
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev="${COMP_WORDS[COMP_CWORD-1]}"

  local opts="
    -client --client
    -c -conf --conf
    -d -debug --debug
    -f -force --force
    -l -log --log
    -server --server
    -v -verbose --verbose
    -virtio --virtio
    -h -help --help
  "
  case "$prev" in
    -conf*|--conf*)
      COMPREPLY=($(compgen -f -- "$cur"))
      return 0
      ;;
  esac

  COMPREPLY=($(compgen -W "$opts" -- "$cur"))
  return 0
}

complete -F _authstor_completions authstor{,.sh,-client,-server}
