# ESO msgsend(8) completion                            -*- shell-script -*-
#
# @file
# @copyright
#   SPDX-FileCopyrightText: 2020-2021, 2024-2025 European Southern Observatory (ESO) @n
#   SPDX-License-Identifier: LGPL-3.0-only
#
# @brief ESO msgsend bash completion

_msgsend()
{
    local cur prev words cword
    _init_completion -n : || return

    case $prev in
        --version|-h|--help|-t|--reply-timeout|-T|--connect-timeout)
            # nothing that can be completed here
            return
            ;;
        -u|--uri)
            compopt -o nospace
            COMPREPLY=( $( compgen -W '
              opcua.rr://
              zpb.rr://
              ' -- "$cur" ) )
            __ltrim_colon_completions "$cur"
            return
            ;;
    esac

    if [[ "$cur" == -* ]]; then
        COMPREPLY=( $( compgen -W '
          -h --help
          -v --verbose
             --version
          -t --reply-timeout
          -T --connect-timeout
          -u --uri
             --consul-addr
          ' -- "$cur" ) )
        return
    fi

    methods="$(/usr/bin/icd_ls_rr)"
    COMPREPLY=( $( compgen -W "$methods" -- "$cur" ) )
    __ltrim_colon_completions "$cur"
} &&
complete -F _msgsend msgsend msgsend.py

# ex: ts=4 sw=4 et filetype=sh
