File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ cross_platform = 2to3.bash \
8282 dmypy.bash \
8383 dnssec-keygen.bash \
8484 dnsspoof.bash \
85+ doas.bash \
8586 dot.bash \
8687 dpkg.bash \
8788 dpkg-source.bash \
Original file line number Diff line number Diff line change 1+ # doas(1) completion
2+
3+ _comp_cmd_doas ()
4+ {
5+ local cur prev words cword was_split comp_args
6+ _comp_initialize -s -- " $@ " || return
7+
8+ local noargopts=' !(-*|*[uCLs]*)'
9+
10+ local i
11+ for (( i = 1 ; i <= cword; i++ )) ; do
12+ if [[ ${words[i]} != -* ]]; then
13+ local PATH=$PATH :/sbin:/usr/sbin:/usr/local/sbin
14+ local root_command=${words[i]}
15+ local _comp_root_command=$1
16+ _comp_command_offset " $i "
17+ return
18+ fi
19+ [[ ${words[i]} == -@ (${noargopts} [uCLs]) ]] &&
20+ (( i++ ))
21+ done
22+
23+ # shellcheck disable=SC2254 # glob $noargopts should not be quoted
24+ case $prev in
25+ -${noargopts} u)
26+ _comp_compgen -- -u
27+ return
28+ ;;
29+ -${noargopts} C)
30+ _comp_compgen_filedir
31+ return
32+ ;;
33+ -${noargopts} [Ls])
34+ return
35+ ;;
36+ esac
37+
38+ [[ $was_split ]] && return
39+
40+ if [[ $cur == -* ]]; then
41+ _comp_compgen_usage
42+ [[ ${COMPREPLY-} == * = ]] && compopt -o nospace
43+ return
44+ fi
45+ } &&
46+ complete -F _comp_cmd_doas doas
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ EXTRA_DIST = \
140140 test_dmypy.py \
141141 test_dnssec_keygen.py \
142142 test_dnsspoof.py \
143+ test_doas.py \
143144 test_dot.py \
144145 test_dpkg.py \
145146 test_dpkg_deb.py \
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+
4+ class TestDoas :
5+ @pytest .mark .complete ("doas -" , require_cmd = True )
6+ def test_1 (self , completion ):
7+ assert completion
8+
9+ @pytest .mark .complete ("doas cd foo" , cwd = "shared/default" )
10+ def test_2 (self , completion ):
11+ assert completion == ".d/"
12+ assert not completion .endswith (" " )
13+
14+ @pytest .mark .complete ("doas sh share" )
15+ def test_3 (self , completion ):
16+ assert completion == "d/"
17+ assert not completion .endswith (" " )
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ display
7979dmesg
8080dmypy
8181dnsspoof
82+ doas
8283dpkg
8384dpkg-deb
8485dpkg-query
You can’t perform that action at this time.
0 commit comments