#compdef prefix

autoload -U is-at-least

_prefix() {
    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[@]}" : \
'-c+[Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty]:when:(always auto never)' \
'--color=[Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty]:when:(always auto never)' \
'-d+[Set delimiter string to print after each FIX field]:delimiter: ' \
'--delimiter=[Set delimiter string to print after each FIX field]:delimiter: ' \
'-S+[Summarise each fix message based on an optional template]' \
'--summary=[Summarise each fix message based on an optional template]' \
'-o[Only print FIX messages]' \
'--only-fix[Only print FIX messages]' \
'--porcelain[print FIX messages closer to standard format, same as --delimiter \\x01 --strip]' \
'-r[Combine any repeating groups into a single field with a comma delimited value]' \
'--repeating[Combine any repeating groups into a single field with a comma delimited value]' \
'-f[Only consider full FIX messages containing both BeginString and Checksum]' \
'--strict[Only consider full FIX messages containing both BeginString and Checksum]' \
'-s[Strip the whitespace around the = in each field]' \
'--strip[Strip the whitespace around the = in each field]' \
'-t[Translate tag numbers on non FIX message lines]' \
'--tag[Translate tag numbers on non FIX message lines]' \
'-v[Translate the values of some tags (for Side\: 1 -> Buy)]' \
'--value[Translate the values of some tags (for Side\: 1 -> Buy)]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::message -- FIX message to be parsed, if not provided will look for a message piped through stdin:' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_prefix" ]; then
    _prefix "$@"
else
    compdef _prefix prefix
fi
