#compdef ptx

autoload -U is-at-least

_ptx() {
    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[@]}" : \
'-F+[ptx-help-flag-truncation]:STRING:_default' \
'--flag-truncation=[ptx-help-flag-truncation]:STRING:_default' \
'-M+[ptx-help-macro-name]:STRING:_default' \
'--macro-name=[ptx-help-macro-name]:STRING:_default' \
'--format=[]: :(roff tex)' \
'-S+[ptx-help-sentence-regexp]:REGEXP:_default' \
'--sentence-regexp=[ptx-help-sentence-regexp]:REGEXP:_default' \
'-W+[ptx-help-word-regexp]:REGEXP:_default' \
'--word-regexp=[ptx-help-word-regexp]:REGEXP:_default' \
'-b+[ptx-help-break-file]:FILE:_files' \
'--break-file=[ptx-help-break-file]:FILE:_files' \
'-g+[ptx-help-gap-size]:NUMBER:_default' \
'--gap-size=[ptx-help-gap-size]:NUMBER:_default' \
'-i+[ptx-help-ignore-file]:FILE:_files' \
'--ignore-file=[ptx-help-ignore-file]:FILE:_files' \
'-o+[ptx-help-only-file]:FILE:_files' \
'--only-file=[ptx-help-only-file]:FILE:_files' \
'-w+[ptx-help-width]:NUMBER:_default' \
'--width=[ptx-help-width]:NUMBER:_default' \
'-A[ptx-help-auto-reference]' \
'--auto-reference[ptx-help-auto-reference]' \
'-G[ptx-help-traditional]' \
'--traditional[ptx-help-traditional]' \
'-O[ptx-help-roff]' \
'-T[ptx-help-tex]' \
'-R[ptx-help-right-side-refs]' \
'--right-side-refs[ptx-help-right-side-refs]' \
'-f[ptx-help-ignore-case]' \
'--ignore-case[ptx-help-ignore-case]' \
'-r[ptx-help-references]' \
'--references[ptx-help-references]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::file:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_ptx" ]; then
    _ptx "$@"
else
    compdef _ptx ptx
fi
