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

function _udiskie
{
  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)'{-a,--automount}"[automount new devices]"
    '(-a)'{-A,--no-automount}"[disable automounting]"
    '(-N)'{-n,--notify}"[show popup notifications]"
    '(-n)'{-N,--no-notify}"[disable notifications]"
    '(--no-appindicator)'--appindicator"[use appindicator for status icon]"
    '(--appindicator)'--no-appindicator"[don't use appindicator]"
    '(-T -s)'{-t,--tray}"[show tray icon]"
    '(-T -t)'{-s,--smart-tray}"[auto hide tray icon]"
    '(-t -s)'{-T,--no-tray}"[disable tray icon]"
    {-m,--menu}"[set behaviour for tray menu]:traymenu:(flat nested)"
    '(--no-password-cache)'--password-cache"[set timeout for passwords of encrypted devices to N minutes]:minutes"
    '(--password-cache)'--no-password-cache"[don't cache passwords for encrypted devices]"
    '(-P)'{-p,--password-prompt}"[Command for password retrieval]:passwordialog:->pprompt"
    '(-p)'{-P,--no-password-prompt}"[Disable unlocking]"
    '(-F)'{-f,--file-manager}"[set program for browsing directories]:filemanager:_path_commands"
    '(-f)'{-F,--no-file-manager}"[disable browsing]"
    '(--no-event-hook)'--event-hook"[execute this command on events]:minutes"
    '(--event-hook)'--no-event-hook"[don't execute event handler]"
  )
  _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
      ;;
  esac

  return ret
}

_udiskie "$@"
