Skip to content

Commit

Permalink
feat(inotifywait): generate exclude filenames prefixed by @
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed May 13, 2024
1 parent 0e9e12a commit 9abd0ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
15 changes: 15 additions & 0 deletions completions/inotifywait
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ _comp_cmd_inotifywait()
return
fi

if [[ $cur == @* ]]; then
# TODO: Or another way is to add -P to _comp_compgen, automatically
# arrange `-c "${cur#$prefix}"`, and other processing to filenames are
# performed before prefixing `-P "$prefix"`.
# TODO: Also, I think there are many similar cases in the codebase.
# ./completions/7z:31: _comp_compgen -c "${cur#*@}" -- -P"${opt}${cur%%@*}@" -f
# ./completions/upgradepkg:18: _comp_compgen -- -P "$prev%" -f -X "!*.@(t[bgxl]z)" || nofiles=set
# If we extend -P usage to others, there are even more cases where "-c
# cur" is adjusted at the same time.
local files
_comp_compgen -v files -c "${cur:1}" filedir -f &&
_comp_compgen -R -- -W '"${files[@]}"' -P @ &&
return 0
fi

_comp_compgen_filedir
} &&
complete -F _comp_cmd_inotifywait inotifywait inotifywatch
Expand Down
8 changes: 8 additions & 0 deletions test/t/test_inotifywait.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ def test_4(self, completion):
"""
assert "ab/" in completion

@pytest.mark.complete("inotifywait @a", cwd="_filedir")
def test_5(self, completion):
"""Test for the specification of the exclude filenames, which
has the form `@filename`.
"""
assert "@ab/" in completion

0 comments on commit 9abd0ed

Please sign in to comment.