#compdef udiskie-mount
# vim: ft=zsh sts=2 sw=2 ts=2

function _udiskie-mount
{
  local context curcontext="$curcontext" line state ret=1
  local args tmp
  typeset -A opt_args

  args=(
    '(- *)'{-h,--help}"[show help]"
    '(- *)'{-V,--version}"[show version]"
    '(-q)'{-v,--verbose}"[more output]"
    '(-v)'{-q,--quiet}"[less output]"
    '(-C)'{-c,--config}"[set config file]:file:_files"
    '(-c)'{-C,--no-config}"[don't use config file]"
    '(*)'{-a,--all}"[unmount all devices]"
    '(-R)'{-r,--recursive}"[recursively add devices]"
    '(-r)'{-R,--no-recursive}"[disable recursive mounting]"
    {-o,--options}"[set filesystem options]:file system option"
    '(-P)'{-p,--password-prompt}"[Command for password retrieval]:passwordialog:->pprompt"
    '(-p)'{-P,--no-password-prompt}"[Disable unlocking]"
    '*:dev or dir:->udevordir'
  )
  _arguments -C -s "$args[@]" && ret=0

  case "$state" in
    pprompt)
      _alternative \
        'builtins:builtin prompt:(builtin:tty builtin:gui)' \
        'commands:command name:_path_commands' \
        && ret=0
      ;;

    udevordir)
      local dev_tmp mp_tmp
      dev_tmp=( $(udiskie-info -a) )
      _alternative \
        'device-paths: device path:_canonical_paths -A dev_tmp -N device-paths device\ path' \
        && ret=0
      ;;
  esac
  return ret
}

_udiskie-mount "$@"
