Skip to content

feat(cli): bash and zsh completion scripts with an anti-drift test#791

Merged
Chemaclass merged 2 commits into
mainfrom
feat/778-shell-completions
Jul 14, 2026
Merged

feat(cli): bash and zsh completion scripts with an anti-drift test#791
Chemaclass merged 2 commits into
mainfrom
feat/778-shell-completions

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #778

bashunit has 8 subcommands and ~60 flags but no shell completion — discoverability required --help round-trips. Static scripts drift, so the contract is enforced by a CI test.

💡 Changes

  • Ship completions/bashunit.bash (plain compgen -W, works on bash 3.2) and completions/_bashunit (zsh _arguments): subcommands, every test flag with value hints (--jobs auto, --output tap, file completion for --env/reports), and the 66 assertion names after bashunit assert
  • Anti-drift unit test extracts the flag list from the option-parsing case arms in the CLI and compares it against both scripts (assertions too) — verified: adding a fake flag to the CLI fails the test until completions are updated
  • Syntax checks (bash -n, zsh -n, skipped without zsh); docs installation section + README pointer

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
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 14, 2026
@Chemaclass Chemaclass self-assigned this Jul 14, 2026
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.
@Chemaclass Chemaclass merged commit 23810b3 into main Jul 14, 2026
49 of 50 checks passed
@Chemaclass Chemaclass deleted the feat/778-shell-completions branch July 14, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant