Skip to content

Commit

Permalink
nsupdate: new completion
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Mar 20, 2019
1 parent dd80f35 commit 80ba367
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ bashcomp_DATA = 2to3 \
_nmcli \
nproc \
nslookup \
nsupdate \
ntpdate \
oggdec \
op \
Expand Down
40 changes: 40 additions & 0 deletions completions/nsupdate
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# bash completion for nsupdate(1) -*- shell-script -*-

_nsupdate()
{
local cur prev words cword
_init_completion || return

case $prev in
-*[VLprtu])
return
;;
-*k)
_filedir key
return
;;
-*R)
cur=${cur:=/dev/}
_filedir
return
;;
-*y)
if [[ $cur == h* ]]; then
COMPREPLY=( $( compgen -W "hmac-{md5,sha{1,224,256,384,512}}" \
-S : -- "$cur" ) )
[[ $COMPREPLY == *: ]] && compopt -o nospace
fi
return
;;
esac

if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
return
fi

_filedir
} &&
complete -F _nsupdate nsupdate

# ex: filetype=sh
1 change: 1 addition & 0 deletions test/t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ EXTRA_DIST = \
test_nmcli.py \
test_nproc.py \
test_nslookup.py \
test_nsupdate.py \
test_ntpdate.py \
test_objcopy.py \
test_objdump.py \
Expand Down
12 changes: 12 additions & 0 deletions test/t/test_nsupdate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest


class TestNsupdate:

@pytest.mark.complete("nsupdate ")
def test_1(self, completion):
assert completion

@pytest.mark.complete("nsupdate -")
def test_2(self, completion):
assert completion

0 comments on commit 80ba367

Please sign in to comment.