Bash completion script for regtest.py

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. :slight_smile:

#/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

3 Likes

This is nice!

My script allows for a wild card by project e.g. run-em-all vvff for Very Vile Fairy File, or run-em-all ai for Ailihphilia. I always meant to establish whether my scripts were level 1, 2 or 3 (meaning, level 1 is basic “does the walkthrough work,” 2 is major features, 3 is details) but never got around to it. So I appreciate this reminder.

Regtest has helped so much.