#compdef age-plugin-yubikey

autoload -U is-at-least

_age-plugin-yubikey() {
  typeset -A opt_args
  typeset -a _arguments_options
  local ret=1

  if is-at-least 5.2; then
      _arguments_options=(-s -S -C)
  else
      _arguments_options=(-s -C)
  fi

  local context curcontext="$curcontext" state line

  _arguments "${_arguments_options[@]}" : \
    '(-h --help)'{-h,--help}'[Print this help message and exit]' \
    '(-V --version)'{-V,--version}'[Print version info and exit]' \
    '(-f --force)'{-f,--force}'[Force --generate to overwrite a filled slot]' \
    '(-g --generate)'{-g,--generate}'[Generate a new YubiKey identity]' \
    '(-i --identity)'{-i,--identity}'[Print identities stored in connected YubiKeys]' \
    '(-l --list)'{-l,--list}'[List recipients for age identities in connected YubiKeys]' \
    '--list-all[List recipients for all YubiKey keys that are compatible with age]' \
    '--name[Name for the generated identity (Default: age identity '\''HEX_TAG'\'')]:NAME:' \
    '--pin-policy[Default: once]:PIN-POLICY:(always once never)' \
    '--serial[Specify which YubiKey to use, if more than one is plugged in]:SERIAL:' \
    '--slot[Specify which slot to use (Default: first usable slot)]:SLOT:' \
    '--touch-policy[Default: always]:TOUCH-POLICY:(always cached never)' \
    "*::: :->age-plugin-yubikey" \
    && ret=0
}

_age-plugin-yubikey "$@"
