feat(cli): bash and zsh completion scripts with an anti-drift test#791
Merged
Conversation
Ship static completion scripts under completions/ for bash (completions/bashunit.bash, plain compgen -W, works on bash 3.2) and zsh (completions/_bashunit, _arguments spec): the 8 subcommands, every flag of the test subcommand with value hints (--jobs auto, --output tap, file completion for -e/--env and report paths), and the 66 public assertion names after 'bashunit assert'. An anti-drift unit test extracts the flag list from the option-parsing case arms in src/main.sh and compares it against both scripts (plus the assertion list against src/assert*.sh), so a new CLI flag fails CI until the completions are updated. Includes bash -n / zsh -n syntax checks. Docs installation section and README pointer added. Closes #778
compgen word-splitting into COMPREPLY is intentional (mapfile needs bash 4+, scripts target 3.2); the tr char-map in the anti-drift test maps punctuation to spaces on purpose. Both flagged by CI shellcheck.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Related #778
bashunit has 8 subcommands and ~60 flags but no shell completion — discoverability required
--helpround-trips. Static scripts drift, so the contract is enforced by a CI test.💡 Changes
completions/bashunit.bash(plaincompgen -W, works on bash 3.2) andcompletions/_bashunit(zsh_arguments): subcommands, everytestflag with value hints (--jobs auto,--output tap, file completion for--env/reports), and the 66 assertion names afterbashunit assertbash -n,zsh -n, skipped without zsh); docs installation section + README pointer