summaryrefslogtreecommitdiffstats
path: root/completions/arp
diff options
context:
space:
mode:
Diffstat (limited to 'completions/arp')
-rw-r--r--completions/arp38
1 files changed, 20 insertions, 18 deletions
diff --git a/completions/arp b/completions/arp
index 922e800..3d1669a 100644
--- a/completions/arp
+++ b/completions/arp
@@ -1,43 +1,45 @@
-# arp(8) completion -*- shell-script -*-
+# arp(8) completion -*- shell-script -*-
-_arp()
+_comp_cmd_arp()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[iApfHt]*)'
+ # shellcheck disable=SC2254
case $prev in
- --device | -!(-*)i)
- _available_interfaces -a
+ --device | -${noargopts}i)
+ _comp_compgen_available_interfaces -a
return
;;
- --protocol | -!(-*)[Ap])
+ --protocol | -${noargopts}[Ap])
# TODO protocol/address family
return
;;
- --file | -!(-*)f)
- _filedir
+ --file | -${noargopts}f)
+ _comp_compgen_filedir
return
;;
- --hw-type | -!(-*)[Ht])
+ --hw-type | -${noargopts}[Ht])
# TODO: parse from --help output?
- COMPREPLY=($(compgen -W 'ash ether ax25 netrom rose arcnet \
- dlci fddi hippi irda x25 eui64' -- "$cur"))
+ _comp_compgen -- -W 'ash ether ax25 netrom rose arcnet dlci fddi
+ hippi irda x25 eui64'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
- local args
- _count_args "" "@(--device|--protocol|--file|--hw-type|-!(-*)[iApfHt])"
- case $args in
+ local REPLY
+ _comp_count_args -a "@(--device|--protocol|--file|--hw-type|-${noargopts}[iApfHt])"
+ case $REPLY in
1)
local ips=$("$1" -an | command sed -ne \
's/.*(\([0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}\)).*/\1/p')
- COMPREPLY=($(compgen -W '$ips' -- "$cur"))
+ _comp_compgen -- -W '$ips'
;;
2)
# TODO if -d mode: "pub"; if not -f mode: hw_addr
@@ -54,6 +56,6 @@ _arp()
;;
esac
} &&
- complete -F _arp arp
+ complete -F _comp_cmd_arp arp
# ex: filetype=sh