summaryrefslogtreecommitdiffstats
path: root/completions/iperf
blob: 016881463ac7a14538b8e48a18478c85d24847ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# iperf(1) completion                                      -*- shell-script -*-

_comp_cmd_iperf()
{
    local cur prev words cword was_split comp_args
    _comp_initialize -s -n : -- "$@" || return

    local noargopts='!(-*|*[ilpwMXbntLPTZCkOSAfIoFBcxy]*)'
    # shellcheck disable=SC2254
    case $prev in
        --help | --version | --interval | --len | --port | --window | --mss | --bandwidth | \
            --num | --time | --listenport | --parallel | --ttl | --linux-congestion | --omit | \
            --congestion | --bytes | --blockcount | --cport | --set-mss | --flowlabel | \
            --title | --tos | --affinity | --rcv-timeout | --server-bitrate-limit | \
            --idle-timeout | --time-skew-threshold | --xbind | --nstreams | --connect-timeout | \
            --bitrate | --pacing-timer | --fq-rate | --length | --dscp | --extra-data | \
            --username | -${noargopts}[hvilpwMXbntLPTZCkOSA])
            return
            ;;
        --format | -${noargopts}f)
            local formats=$(
                "$1" --help 2>&1 |
                    command sed -ne 's/^.*--format .*\[\([a-zA-Z]\{1,\}\)\].*/\1/p' |
                    command sed -e 's/./& /g'
            )
            _comp_compgen -- -W '$formats'
            return
            ;;
        --pidfile | -${noargopts}I)
            _comp_compgen_filedir pid
            return
            ;;
        --output | --fileinput | --authorized-users-path | -${noargopts}[oF])
            _comp_compgen_filedir
            return
            ;;
        --bind | -${noargopts}B)
            _comp_compgen_available_interfaces -a
            _comp_compgen -a ip_addresses -a
            return
            ;;
        --bind-dev)
            _comp_compgen_available_interfaces -a
            return
            ;;
        --client | -${noargopts}c)
            _comp_compgen_known_hosts -- "$cur"
            return
            ;;
        --reportexclude | -${noargopts}x)
            _comp_compgen -- -W 'C D M S V'
            return
            ;;
        --reportstyle | -${noargopts}y)
            _comp_compgen -- -W 'C'
            return
            ;;
        --logfile)
            _comp_compgen_filedir log
            return
            ;;
        --rsa-private-key-path | --rsa-public-key-path)
            _comp_compgen_filedir pem
            return
            ;;
    esac

    [[ $was_split ]] && return

    # Filter mode specific options
    local -a filter=(cat)
    local i
    for i in "${words[@]}"; do
        case $i in
            -s | --server)
                filter=(command sed -e '/^Client.specific/,/^\(Server.specific.*\)\{0,1\}$/d')
                ;;
            -c | --client)
                filter=(command sed -e '/^Server.specific/,/^\(Client.specific.*\)\{0,1\}$/d')
                ;;
        esac
    done
    [[ $filter != cat ]] && filter+=(-e '/--client/d' -e '/--server/d')

    _comp_compgen_help - <<<"$("$1" --help 2>&1 | "${filter[@]}")"
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
    complete -F _comp_cmd_iperf iperf iperf3

# ex: filetype=sh