Skip to content

Commit fa696e6

Browse files
yedayakscop
authored andcommitted
feat(ip): Add completion for monitor subcommand
Currently it stops after completing the first option, although you should be able to choose multiple options. Also include a test that is skipped if the monitor subcommand doesn't exist.
1 parent be0010e commit fa696e6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

completions/ip

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,14 @@ _comp_cmd_ip()
357357
all) ;;
358358
*)
359359
((cword == subcword)) &&
360-
_comp_compgen -- -W 'help all'
360+
_comp_compgen_split -- "help all $(
361+
{
362+
"$1" -c=never monitor help || "$1" monitor help
363+
} 2>&1 | command sed -e \
364+
'/OBJECTS := /,/[^|]$/!d' -e \
365+
's/OBJECTS := *//' -e \
366+
's/|//g'
367+
)"
361368
;;
362369
esac
363370
;;

test/t/test_ip.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ def test_2(self, completion):
1414
def test_r_r(self, completion):
1515
assert completion
1616

17+
@pytest.mark.complete(
18+
"ip monitor ",
19+
require_cmd=True,
20+
skipif="ip monitor help 2>/dev/null; (( $? != 255 ))",
21+
)
22+
def test_monitor(self, completion):
23+
assert "neigh" in completion
24+
assert "all" in completion
25+
1726
@pytest.mark.complete("ip -", require_cmd=True)
1827
def test_options(self, completion):
1928
assert "-family" in completion

0 commit comments

Comments
 (0)