#compdef txt

autoload -U is-at-least

_txt() {
    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[@]}" : \
'--completions=[Print shell completion script and exit]:SHELL:(bash elvish fish powershell zsh)' \
'--install-completions=[Install shell completions into your shell'\''s startup file and exit]::SHELL:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
'::path -- File or directory to open:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_txt" ]; then
    _txt "$@"
else
    compdef _txt txt
fi
