Shell completion for fish, bash, zsh and PowerShell #44

Closed
opened 2026-10-22 23:44:49 -05:00 by jeff · 1 comment
Owner

Shell completion for fish, bash, zsh and PowerShell.

Decisions

  • zfj answers its own completion (docs/adr/0007-completion-is-answered-by-zfj.md). A hidden zfj __complete <words> is given every word after zfj, the last being the partial word (possibly empty). It answers one candidate to a line as value<TAB>description, already prefix-matched, and then a directive line: :files, :dirs or :none. Each shell's completion script only hands it the line and offers what comes back. A script reads a directive it doesn't know as :none, so the protocol can grow.
  • Never noisy: __complete writes nothing to stderr and always exits 0.
  • What is completed:
    • Command words, group commands, options, and the values an option lists.
    • Operation names for zfj op, and an operation's params.
    • Local values: instance names, workflow files in the clone, files, directories.
    • Nothing from the instance (numbers, labels, repositories, users), so no network and no token while completing.
  • Global options are offered only before the command, as ADR 0003 accepts them.
  • Descriptions come from command summaries, option notes and operation summaries. The bash script drops them.
  • zfj completion <fish|bash|zsh|powershell> prints the script. The scripts are plain files in src/cli/completions/, embedded with @embedFile, and installed as files without running zfj, since a cross build cannot run what it builds.
  • Testing: unit tests on __complete, and a flake check that loads each script in its real shell and completes zfj iss and zfj issue list --st.

Deferred

Completing values from the instance: issue, pull request and run numbers, labels, repositories, users.

Children

  • #45 __complete, zfj completion, fish
  • #46 bash
  • #47 zsh
  • #48 PowerShell
  • #49 local values
  • #50 packaging and README
Shell completion for fish, bash, zsh and PowerShell. ## Decisions - **zfj answers its own completion** (`docs/adr/0007-completion-is-answered-by-zfj.md`). A hidden `zfj __complete <words>` is given every word after `zfj`, the last being the partial word (possibly empty). It answers one candidate to a line as `value<TAB>description`, already prefix-matched, and then a directive line: `:files`, `:dirs` or `:none`. Each shell's **completion script** only hands it the line and offers what comes back. A script reads a directive it doesn't know as `:none`, so the protocol can grow. - **Never noisy:** `__complete` writes nothing to stderr and always exits 0. - **What is completed:** - Command words, group commands, options, and the values an option lists. - Operation names for `zfj op`, and an operation's params. - Local values: instance names, workflow files in the clone, files, directories. - Nothing from the instance (numbers, labels, repositories, users), so no network and no token while completing. - **Global options** are offered only before the command, as ADR 0003 accepts them. - **Descriptions** come from command summaries, option notes and operation summaries. The bash script drops them. - **`zfj completion <fish|bash|zsh|powershell>`** prints the script. The scripts are plain files in `src/cli/completions/`, embedded with `@embedFile`, and installed as files without running zfj, since a cross build cannot run what it builds. - **Testing:** unit tests on `__complete`, and a flake check that loads each script in its real shell and completes `zfj iss` and `zfj issue list --st`. ## Deferred Completing values from the instance: issue, pull request and run numbers, labels, repositories, users. ## Children - [ ] #45 `__complete`, `zfj completion`, fish - [ ] #46 bash - [ ] #47 zsh - [ ] #48 PowerShell - [ ] #49 local values - [ ] #50 packaging and README
jeff referenced this issue from a commit 2026-10-23 00:40:19 -05:00
jeff referenced this issue from a commit 2026-10-23 00:40:19 -05:00
jeff referenced this issue from a commit 2026-10-23 00:40:20 -05:00
Author
Owner

Done: shell completion for fish, bash, zsh and PowerShell is on main, and ships in v0.8.0.

Each script is checked in its real shell by the completion flake check, PowerShell under both Standard and Legacy argument passing. Completing values from the instance (numbers, labels, repositories, users) is still deferred.

Done: shell completion for fish, bash, zsh and PowerShell is on main, and ships in v0.8.0. - #45 `__complete`, `zfj completion`, fish: a86e193 - #46 bash: 87c9ae6 - #47 zsh: a38407d - #48 PowerShell: de4a027 - #49 instances, workflow files, files and directories: efed0aa - #50 packaging and README: 00c098c Each script is checked in its real shell by the `completion` flake check, PowerShell under both Standard and Legacy argument passing. Completing values from the instance (numbers, labels, repositories, users) is still deferred.
jeff closed this issue 2026-10-23 00:40:50 -05:00
Sign in to join this conversation.
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
jeff/zfj#44
No description provided.