#6086 [Other] Terminal: shell tab completion for the strata command
closed · @ackalker · 3 comments · View on GitHub
Setup & installServer & APIAMD / HIPNVIDIA / CUDADocumentationLinux
Description
Problem: typing `strata ` and pressing Tab in bash, zsh or fish completes nothing. The command grammar lives in `strata_cli/cli.py` (`parser()`, about 25 subcommands and many nested ones), and there is no way to get it into a shell. Workaround today: none, short of hand-writing a completion script, which drifts from the grammar as soon as a subcommand changes. Version and system this was written and tested on: `strata 0.2.15 (build 0.1.61; python 3.13.14)` from a source checkout at `c77572806`. NVIDIA GeForce RTX 5080 with 16 GB VRAM, plus an AMD Radeon 610M iGPU; 60 GB RAM; CachyOS Linux, kernel 7.3.4-1-cachyos, x86_64. No GPU work is involved: this is a CLI-only change, validated with the mock-free Terminal test suite. Proposal (small, opt-in): a `strata complete --shell bash|zsh|fish` subcommand that prints a completion script generated from the installed CLI's own `argparse` grammar with the optional [`shtab`](https://github.com/iterativ/shtab) package, so there is no second grammar to maintain. - `strata_cli/cli.py`: one subparser and one ~10-line handler that prints `shtab.complete(parser(), shell=...)` to stdout. - `shtab` is imported lazily inside the handler only. The default path (`serve`, `launch`, `status`, …) changes by zero lines, and the hash-locked Terminal bundle gains no new package. Without `shtab` the command prints what to install and exits 2. - Tests: `tests/terminal/test_shell_completions.py` regenerates each script, checks it names every current top-level command and parses (`bash -n`, `zsh -n`, `fish -n`). - Docs: one short section in `docs/TERMINAL.md`. - No installer changes: the user adds one line to their shell profile. Limits: PowerShell output is not generated (shtab has no PowerShell target); value completion (profile names, model IDs) is not in this scope. Subcommand and flag completion is the whole grammar already in the parser. Related: I found no existing issue or PR about shell completion (searched "tab completion", "shell completion", "autocomplete", "shtab", "argcomplete").
Related on this site
Quick links to related pages.