I made a bash completion script for Zarf’s excellent regtest tool a while ago and thought I should share it.
You’ll probably want to tweak it to fit your needs (I use .org as an extension for my test cases which I doubt is universal) but it should be a start.
#/usr/bin/env bash
_regtest_completions()
{
TEST_PATTERN="*.org"
cur="${COMP_WORDS[COMP_CWORD]}"
if [ "${#COMP_WORDS[@]}" == "2" ]; then
list=$(ls $TEST_PATTERN)
fi
if [ "${#COMP_WORDS[@]}" -ge "3" ]; then
testfile=${COMP_WORDS[1]}
list=$(${COMP_WORDS[0]} "${testfile}" -l)
fi
COMPREPLY=($(compgen -W "${list}" -- ${cur}) )
}
complete -F _regtest_completions regtest.py