#compdef mdcat

autoload -U is-at-least

_mdcat() {
    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[@]}" \
'--columns=[Maximum number of columns to use for output]:COLUMNS: ' \
'-c[Disable all colours and other styles]' \
'--no-colour[Disable all colours and other styles]' \
'-l[Do not load remote resources like images]' \
'--local[Do not load remote resources like images]' \
'--fail[Exit immediately if any error occurs processing an input file]' \
'--detect-terminal[Print detected terminal name and exit]' \
'(-c --no-colour)--ansi[Skip terminal detection and only use ANSI formatting]' \
'-p[Paginate the output of mdcat with a pager like less]' \
'--paginate[Paginate the output of mdcat with a pager like less]' \
'-P[Do not paginate output (default). Overrides an earlier --paginate]' \
'--no-pager[Do not paginate output (default). Overrides an earlier --paginate]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::filenames -- Files to read.  If - read from standard input instead:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_mdcat" ]; then
    _mdcat "$@"
else
    compdef _mdcat mdcat
fi
