#compdef tw

autoload -U is-at-least

_tw() {
    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[@]}" : \
'*--multiparts=[Paths to be opened and concatenated vertically.]:MULTIPARTS:_default' \
'-f+[Specifies the input format. By default, the format is selected based on the file extension]:FORMAT:(dsv csv tsv parquet jsonl json arrow fwf sqlite excel logfmt avro)' \
'--format=[Specifies the input format. By default, the format is selected based on the file extension]:FORMAT:(dsv csv tsv parquet jsonl json arrow fwf sqlite excel logfmt avro)' \
'--sqlite-key=[Sets the key for sqlite (if required)]:SQLITE_KEY:_default' \
'--infer-schema=[Specifies the method to infer the schema.]:INFER_SCHEMA:(no fast safe)' \
'--separator=[Character used as the field separator or delimiter while loading DSV files.]:SEPARATOR:_default' \
'--quote-char=[Character used to quote fields while loading DSV files.]:QUOTE_CHAR:_default' \
'--widths=[A comma-separated list of widths, which specifies the column widths for FWF files.]:WIDTHS:_default' \
'--separator-length=[Specifies the separator length for FWF files.]:SEPARATOR_LENGTH:_default' \
'--infer-types=[Specifies the types to infer for text-based files.]:INFER_TYPES:_default' \
'--no-header[Specifies if the input does not contain a header row.]' \
'--ignore-errors[Ignores parsing errors while loading.]' \
'--infer-datetimes[Performs additional processing to parse date and datetime columns]' \
'--no-flexible-width[Sets strict column width restrictions for FWF files.]' \
'--truncate-ragged-lines[Truncate ragged lines while reading the file.]' \
'--no-type-inference[Disables type inference]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::resources -- Path(s) to the file(s) to be opened.:_default' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_tw" ]; then
    _tw "$@"
else
    compdef _tw tw
fi
