Skip to content

Commit c7c3c03

Browse files
yedayakscop
authored andcommitted
feat(ip): Complete neigh show and flush
1 parent 216734b commit c7c3c03

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

completions/ip

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ _comp_cmd_ip__link_types()
3737
)"
3838
}
3939

40+
_comp_cmd_ip__neigh_states()
41+
{
42+
_comp_compgen_split -- "$(
43+
{
44+
${1-ip} -c=never neigh help || ${1-ip} neigh help
45+
} 2>&1 | command sed -e \
46+
'/STATE := /,/}/!d' -e \
47+
's/.*{//' -e \
48+
's/}.*//' -e \
49+
's/|/ /g'
50+
)"
51+
}
52+
4053
_comp_cmd_ip()
4154
{
4255
local cur prev words cword comp_args
@@ -344,7 +357,20 @@ _comp_cmd_ip()
344357
# TODO
345358
;;
346359
show | flush)
347-
# TODO
360+
case "$prev" in
361+
nud)
362+
_comp_cmd_ip__neigh_states "$1"
363+
;;
364+
dev)
365+
_comp_compgen_available_interfaces
366+
;;
367+
nomaster | proxy | to | vrf) # TODO - Maybe we can complete vrf here?
368+
:
369+
;;
370+
*)
371+
_comp_compgen -- -W 'proxy to nud vrf dev nomaster'
372+
;;
373+
esac
348374
;;
349375
*)
350376
((cword == subcword)) &&

test/t/test_ip.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ def test_stats(self, completion):
2323
# "link" was one of the first groups added, should always be there
2424
assert "link" in completion
2525

26+
@pytest.mark.complete(
27+
"ip neigh show nud ",
28+
require_cmd=True,
29+
skipif="ip neigh help 2>&1 | grep 'STATE :=' > /dev/null; (( $? != 0 ))",
30+
)
31+
def test_neigh_state(self, completion):
32+
assert "stale" in completion
33+
2634
@pytest.mark.complete(
2735
"ip monitor ",
2836
require_cmd=True,

0 commit comments

Comments
 (0)