#compdef freebsd-update

local flags
flags=(
  '(cron)fetch[Fetch a compressed snapshot or update existing one]'
  '(fetch)cron[Sleep rand(3600) seconds, and then fetch updates]'
  '(install rollback)upgrade[Fetch files necessary for upgrading to a new release]'
  '(upgrade rollback)install[Install the most recently fetched updates or upgrade]'
  '(upgrade install)rollback[Uninstall the most recently installed updates]'
)

_arguments -s \
  '-b[Operate on a system mounted at basedir]:basedir:_files -/' \
  '-d[Store working files in workdir]:workdir:_files -/' \
  '-f[Read configuration options from conffile]:conf file:_files' \
  '-k[Trust an RSA key with SHA256 of KEY]:RSA key:' \
  '-r[Specify the new release]:new release:' \
  '-s[Fetch files from the specified server or server pool]:server:_hosts' \
  '-f[Mail output of cron command, if any, to address]:address:' \
  ':command:_values -S " " -w "commands" $flags[@]'
