Skip to content

completions: incode completions bash|zsh|fish|powershell (#26 item 2) - #29

Merged
blockmandev merged 2 commits into
mainfrom
feat/shell-completions
Oct 22, 2026
Merged

blockmandev merged 2 commits into
mainfrom
feat/shell-completions

Conversation

@blockmandev

Copy link
Copy Markdown
Member

#26 item 2: incode completions <bash|zsh|fish|powershell> prints a completion script.

Generated from a table of the command line (COMPLETION, beside USAGE in main.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

  • Table ⇄ USAGE (and review's) name the same flags, both ways; the subcommands match.
  • The parser accepts every flag and fixed value offered.
  • The scripts run in the real shells on the same cases: bash, PowerShell (TabExpansion2), fish (complete -C), zsh (completion-system builtins stood in for). Each skips where its shell is missing; CI's Linux job now installs fish and zsh so all four run somewhere.
  • Controls: dropping a flag from the table, or the fixed values from the generator, fails the tests.

Verified locally (Windows)

cargo fmt --check clean; clippy: only the existing with_tool_server warning; 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.

#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.
@blockmandev
blockmandev merged commit 47f5cc6 into main Oct 22, 2026
7 checks passed
@blockmandev
blockmandev deleted the feat/shell-completions branch November 15, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant