#compdef sync

autoload -U is-at-least

_sync() {
    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[@]}" : \
'(-d --data)-f[sync-help-file-system]' \
'(-d --data)--file-system[sync-help-file-system]' \
'(-f --file-system)-d[sync-help-data]' \
'(-f --file-system)--data[sync-help-data]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::files:_files' \
&& ret=0
}

(( $+functions[_sync_commands] )) ||
_sync_commands() {
    local commands; commands=()
    _describe -t commands 'sync commands' commands "$@"
}

if [ "$funcstack[1]" = "_sync" ]; then
    _sync "$@"
else
    compdef _sync sync
fi
