#compdef borgreport

autoload -U is-at-least

_borgreport() {
    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[@]}" : \
'*--env-dir=[Directory to look for *.env files containing BORG_* variables for a repository.]:DIR:_files -/' \
'--env-inherit=[Inherit BORG_* variables for a single <REPOSITORY> name from the current environment.]:REPOSITORY:( )' \
'--text-to=[Write the text report to <FILE> instead of stdout.]:FILE:_files' \
'--html-to=[Write the HTML report to <FILE>.]:FILE:_files' \
'--metrics-to=[Write metrics to <FILE>.]:FILE:_files' \
'--mail-to=[Send the report to <ADDR> via \`sendmail\`]:ADDR:_email_addresses' \
'--mail-from=[Send the report from <ADDR> instead of a default]:ADDR:_email_addresses' \
'--glob-archives=[Enforce a glob archives filter for all repositories.]:GLOB:( )' \
'--check=[Enforce to run (or not run) \`borg check\`]' \
'--check-options=[Enforce override of raw \`borg check\` options for all repositories.]:OPTS:( )' \
'--borg-binary=[Local path to a specific '\''borg'\'' binary]:FILE:_files' \
'--max-age-hours=[Threshold to warn when the last archive is older than <HOURS>]:HOURS:( )' \
'--no-progress[Suppress all status updates during processing.]' \
'--help-man[Print an extended help message as input for \`help2man\`]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_borgreport" ]; then
    _borgreport "$@"
else
    compdef _borgreport borgreport
fi
