Skip to content

Commit

Permalink
feat(hash): new completion (#1013)
Browse files Browse the repository at this point in the history
Co-authored-by: Koichi Murase <[email protected]>
  • Loading branch information
scop and akinomyoga authored Jul 20, 2023
1 parent 20c9cea commit 4d0bffb
Show file tree
Hide file tree
Showing 5 changed files with 40 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 @@ -157,6 +157,7 @@ bashcomp_DATA = 2to3 \
_gsctl \
gssdp-discover \
gzip \
hash \
hcitool \
hddtemp \
help \
Expand Down
26 changes: 26 additions & 0 deletions completions/hash
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# hash completion -*- shell-script -*-

_comp_cmd_hash()
{
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local noargopts='!(*[p]*)'
# shellcheck disable=SC2254
case $prev in
-${noargopts}p)
_comp_compgen_filedir
return
;;
esac

if [[ $cur == -* ]]; then
_comp_compgen_help -c help "$1"
return
fi

_comp_compgen_commands
} &&
complete -F _comp_cmd_hash hash

# 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 @@ -221,6 +221,7 @@ EXTRA_DIST = \
test_gssdp_device_sniffer.py \
test_gssdp_discover.py \
test_gzip.py \
test_hash.py \
test_hciattach.py \
test_hciconfig.py \
test_hcitool.py \
Expand Down
11 changes: 11 additions & 0 deletions test/t/test_hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest


class TestHash:
@pytest.mark.complete("hash ", require_cmd=True)
def test_basic(self, completion):
assert completion

@pytest.mark.complete("hash -", require_cmd=True)
def test_options(self, completion):
assert completion
1 change: 1 addition & 0 deletions test/test-cmd-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ grub
gssdp-device-sniffer
gssdp-discover
gzip
hash
hcitool
head
hexdump
Expand Down

0 comments on commit 4d0bffb

Please sign in to comment.