#compdef ffcast

if ! zstyle -t ":completion:${curcontext}options:" sort; then
  zstyle ":completion:${curcontext}options:" sort false
fi

_ffcast() {
  _arguments -S \
    '(-h)*-g+[specify a region in numeric geometry]:geospec:' \
    '(-h)*-x+[select the Xinerama head of ID n]:head id:_ffcast_heads' \
    '(-h)*-s[select a rectangular region by mouse]' \
    '(-h)*-w[select a window by mouse click]' \
    '(-h)*-#+[select a window by window ID]:window id:' \
    '(-h)-b[include window borders hereafter]' \
    '(-h)-f[include window frame hereafter]' \
    '(-h)-i[combine regions by intersection]' \
    '(-h)*-q[be less verbose]' \
    '(-h)*-v[be more verbose]' \
    '(-):command: _command_names -e' \
    '*::arguments: _normal'
#   '(- :)-h[print this help and exit]' \
}

#(( $+functions[_ffcast_commands] )) ||
#_ffcast_commands() {
#  local -a sub_commands
#  sub_commands=( ${${(f)"$(ffcast help)"}/$'\t'/:})
#  _describe -t sub_commands 'sub-command' sub_commands
#}

(( $+functions[_ffcast_heads] )) ||
_ffcast_heads() {
  local -a heads
  heads=( ${${${(f)"$(ffcast -x list)"}#head \#}/: /:} )
  _describe -t heads 'head id' heads
}
