feat(std/cli): shell completion scripts #785

Open
orion wants to merge 2 commits from loop/125-cli-completions into main
Collaborator

Adds Command.completion(shell: Shell): String and the Shell type (Bash, Zsh, Fish, PowerShell) to std/cli: a pure function that turns the declared command tree into the completion script of a shell (CLI slice 3, std/cli half).

  • Completes subcommands (and help) and --flag / --option names of the command the line is in, plus -h and --help, at every depth; option values are left to the shell's file completion.
  • Mechanisms: bash complete -F, zsh #compdef, fish complete -c, PowerShell Register-ArgumentCompleter -Native.
  • Tests (std/cli/tests/completion.test.trb): one golden test per shell, nested path test, a test that an added flag changes every script.
  • Docs: docs/standard-library/cli.md (new section and declarations, skill copy updated by hand to match), docs/design/CLI.md (decision recorded, slice 3 done for std/cli).

No seed, syntax, native or driver change. torb completions <shell> follows as a separate issue after a seed refresh.

Not verified locally (no bootstrap by rule): the golden texts were derived from the generator's algorithm by an independent script, so CI is the first real run. torb docs skill --check may want a regenerated skills/ copy.

Refs #125

Adds `Command.completion(shell: Shell): String` and the `Shell` type (Bash, Zsh, Fish, PowerShell) to `std/cli`: a pure function that turns the declared command tree into the completion script of a shell (CLI slice 3, std/cli half). - Completes subcommands (and `help`) and `--flag` / `--option` names of the command the line is in, plus `-h` and `--help`, at every depth; option values are left to the shell's file completion. - Mechanisms: bash `complete -F`, zsh `#compdef`, fish `complete -c`, PowerShell `Register-ArgumentCompleter -Native`. - Tests (`std/cli/tests/completion.test.trb`): one golden test per shell, nested path test, a test that an added flag changes every script. - Docs: `docs/standard-library/cli.md` (new section and declarations, skill copy updated by hand to match), `docs/design/CLI.md` (decision recorded, slice 3 done for std/cli). No seed, syntax, native or driver change. `torb completions <shell>` follows as a separate issue after a seed refresh. Not verified locally (no bootstrap by rule): the golden texts were derived from the generator's algorithm by an independent script, so CI is the first real run. `torb docs skill --check` may want a regenerated `skills/` copy. Refs #125
docs(cli): record shell completion and mark slice 3 done for std/cli
Some checks are pending
ci / commit messages (pull_request) Waiting to run
ci / what the change touches (pull_request) Waiting to run
ci / gates (pull_request) Blocked by required conditions
pdisc / pdisc (pull_request) Waiting to run
6a6bc7faf2
Some checks are pending
ci / commit messages (pull_request) Waiting to run
ci / what the change touches (pull_request) Waiting to run
ci / gates (pull_request) Blocked by required conditions
Required
Details
pdisc / pdisc (pull_request) Waiting to run
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'loop/125-cli-completions:loop/125-cli-completions'
git switch 'loop/125-cli-completions'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!785
No description provided.