diff options
Diffstat (limited to 'completions/iperf')
-rw-r--r-- | completions/iperf | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/completions/iperf b/completions/iperf index 6347fe0..0168814 100644 --- a/completions/iperf +++ b/completions/iperf @@ -1,69 +1,90 @@ # iperf(1) completion -*- shell-script -*- -_iperf() +_comp_cmd_iperf() { - local cur prev words cword split - _init_completion -s -n : || return + 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 | -!(-*)[hvilpwMbntLPTZCkOSA]) + --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 | -!(-*)f) - COMPREPLY=($(compgen -W 'k m g K M G' -- "$cur")) + --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 ;; - --output | --fileinput | -!(-*)[oF]) - _filedir + --pidfile | -${noargopts}I) + _comp_compgen_filedir pid return ;; - --bind | -!(-*)B) - _available_interfaces -a - _ip_addresses -a - __ltrim_colon_completions "$cur" + --output | --fileinput | --authorized-users-path | -${noargopts}[oF]) + _comp_compgen_filedir return ;; - --client | -!(-*)c) - _known_hosts_real -- "$cur" + --bind | -${noargopts}B) + _comp_compgen_available_interfaces -a + _comp_compgen -a ip_addresses -a return ;; - --reportexclude | -!(-*)x) - COMPREPLY=($(compgen -W 'C D M S V' -- "$cur")) + --bind-dev) + _comp_compgen_available_interfaces -a return ;; - --reportstyle | -!(-*)y) - COMPREPLY=($(compgen -W 'C' -- "$cur")) + --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) - _filedir log + _comp_compgen_filedir log + return + ;; + --rsa-private-key-path | --rsa-public-key-path) + _comp_compgen_filedir pem return ;; esac - $split && return + [[ $was_split ]] && return # Filter mode specific options - local i filter=cat + local -a filter=(cat) + local i for i in "${words[@]}"; do case $i in -s | --server) - filter='command sed -e /^Client.specific/,/^\(Server.specific.*\)\?$/d' + filter=(command sed -e '/^Client.specific/,/^\(Server.specific.*\)\{0,1\}$/d') ;; -c | --client) - filter='command sed -e /^Server.specific/,/^\(Client.specific.*\)\?$/d' + filter=(command sed -e '/^Server.specific/,/^\(Client.specific.*\)\{0,1\}$/d') ;; esac done - [[ $filter != cat ]] && filter+=' -e /--client/d -e /--server/d' + [[ $filter != cat ]] && filter+=(-e '/--client/d' -e '/--server/d') - COMPREPLY=($(compgen -W \ - '$("$1" --help 2>&1 | $filter | _parse_help -)' -- "$cur")) + _comp_compgen_help - <<<"$("$1" --help 2>&1 | "${filter[@]}")" [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && - complete -F _iperf iperf iperf3 + complete -F _comp_cmd_iperf iperf iperf3 # ex: filetype=sh |