Repository navigation
completions: incode completions bash|zsh|fish|powershell (#26 item 2) - #29
Merged
Merged
Conversation
#26 item 2. The parser is hand-written, so there is no argument library to generate completions from: src/completions.rs generates them from a table of the command line, COMPLETION, kept beside USAGE in main.rs. What is completed: every flag; the values of -p, --output-format and --spec-gate; the subcommands in first place (update, review, plugin, mcp, completions) and their verbs (mcp login, plugin add, ...); file names after a path flag; nothing after a free-text one. bash and zsh get a function each over their own word arrays, fish `complete` lines, PowerShell a native argument completer. Tests: - The table and USAGE (and review's USAGE) name the same flags, both ways; the subcommands match USAGE's lines. - The parser takes every flag and every fixed value offered (an error may only be about a combination, never "unknown"); review's flags parse; mcp's verbs are not "unknown"; plugin's are in its help. - The generated scripts run in the real shells on the same cases: bash calling the function, PowerShell through TabExpansion2, fish through `complete -C`, zsh with compadd/_files/compdef stood in for. Each skips, and says so, where its shell is missing; CI's Linux job now installs fish and zsh so every one runs somewhere. - A word that is not a plain token is refused rather than written into a script a shell runs. Controls: dropping --add-dir from the table fails the USAGE test; dropping fixed values from the generator fails bash and PowerShell. Found on the way: a PowerShell default branch written as a bare { } block was a script-block value, printed instead of run; a bare `--` is PowerShell's own token and reaches no completer, so the cases use prefixes.
The shell tests skip where their shell is missing, so a green run did not show the fish or zsh script had run at all. INCODE_TEST_SHELLS names the shells a runner must have; one listed and not found fails the test. CI sets it per runner: Linux bash,fish,zsh,powershell; macOS bash,zsh,powershell; Windows bash,powershell. Control: requiring fish here, where it is not installed, fails fish_completes_from_the_table.
This was referenced Oct 22, 2026
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.
#26 item 2:
incode completions <bash|zsh|fish|powershell>prints a completion script.Generated from a table of the command line (
COMPLETION, besideUSAGEinmain.rs), since the parser is hand-written. It completes flags, the values of-p/--output-format/--spec-gate, the subcommands and their verbs (mcp login,plugin add, …), file names after a path flag, and nothing after free text.Tests
USAGE(andreview's) name the same flags, both ways; the subcommands match.TabExpansion2), fish (complete -C), zsh (completion-system builtins stood in for). Each skips where its shell is missing; CI's Linux job now installsfishandzshso all four run somewhere.Verified locally (Windows)
cargo fmt --checkclean; clippy: only the existingwith_tool_serverwarning;cargo test: lib 2173 passed, bin 59 passed. bash and PowerShell ran for real; fish and zsh are not installed here and skipped — CI (Linux, macOS) is their check.