Skip to content

Commit a0e6b97

Browse files
committed
feat(inotifywait): generate exclude filenames prefixed by @
1 parent eb1b41e commit a0e6b97

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

completions/inotifywait

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ _comp_cmd_inotifywait()
4141
return
4242
fi
4343

44+
if [[ $cur == @* ]]; then
45+
# TODO: Or another way is to add -P to _comp_compgen, automatically
46+
# arrange `-c "${cur#$prefix}"`, and other processing to filenames are
47+
# performed before prefixing `-P "$prefix"`.
48+
# TODO: Also, I think there are many similar cases in the codebase.
49+
# ./completions/7z:31: _comp_compgen -c "${cur#*@}" -- -P"${opt}${cur%%@*}@" -f
50+
# ./completions/upgradepkg:18: _comp_compgen -- -P "$prev%" -f -X "!*.@(t[bgxl]z)" || nofiles=set
51+
# If we extend -P usage to others, there are even more cases where "-c
52+
# cur" is adjusted at the same time.
53+
local files
54+
_comp_compgen -v files -c "${cur:1}" filedir -f &&
55+
_comp_compgen -R -- -W '"${files[@]}"' -P @ &&
56+
return 0
57+
fi
58+
4459
_comp_compgen_filedir
4560
} &&
4661
complete -F _comp_cmd_inotifywait inotifywait inotifywatch fsnotifywait \

test/t/test_inotifywait.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ def test_4(self, completion):
2323
2424
"""
2525
assert "ab/" in completion
26+
27+
@pytest.mark.complete("inotifywait @a", cwd="_filedir")
28+
def test_5(self, completion):
29+
"""Test for the specification of the exclude filenames, which
30+
has the form `@filename`.
31+
32+
"""
33+
assert "@ab/" in completion

0 commit comments

Comments
 (0)