refactor(wt): parse the remaining bins with zarg - #84
Merged
Conversation
wtclean moved to zarg in #82 and the other four were left hand-rolled, which is exactly the drift zarg exists to prevent. One declaration now yields the parser, --help and completions for all five. Branch arguments reuse _wt_branches, the function already backing the wt and wtrm compdefs, rather than a second way to list worktrees. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SdK2s5sJBVLc5Edhm3cZ3H
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.
What this does
#82 moved
wtcleanto zarg and left the other four bins hand-rolled. This finishes the job:wt-list,wt-preview,wt-pickerandwt-shellnow declare their interface once and get the parser,--helpand completions from it.Registered in
generate:completions:plugin— the by-path variant #82 added, since these live in plugins rather than onPATHand the usualcommand -vgate would skip them without saying so.Why this and not #80
#80 should be closed. It did the same job by hand — a
casestatement per script emitting a literal#compdefheredoc — and invented its own by-path Taskfile entry, which would now duplicategenerate:completions:plugin. zarg's whole premise is that a hand-written parser/compdef pair drifts the moment you add a flag, and #80 is four instances of exactly that pair. Superseded on both counts.Load-bearing decisions
complete=_wt_branchesrather than a fresh worktree listing. That function already backs thewtandwtrmcompdefs, so there's one place that knows how to enumerate worktrees for completion.set -euo pipefail, not after. It exits the script itself on a parse error, so it doesn't need-e, and running it under-urisks tripping over its own optional-variable handling for no benefit.wt-previewkeeps the tab-stripping. fzf-tab passes the wholebranch<TAB>pathline as one word, so${branch%%$'\t'*}still applies after zarg binds it.wt-preview, which is already making agh pr viewcall per render.How to confirm
zsh-plugins/wt-core/bin/wt-list --help zsh-plugins/wt-core/bin/wt-list --nope # rc=2, did-you-mean task generate:completionsVerified: all five emit completions that parse under
zsh -n;compinitregisters every one from a scratchfpath(wt-list -> _wt-listand so on);wt-liststill lists and still resolves a single branch;wt-previewstill previews; required positionals are enforced onwt-shell.Not covered by testing
wt-pickerandwt-shellpast their argument handling — both need a TTY, andwt-pickerwith no arguments blocks on fzf by design.🤖 Generated with Claude Code
https://claude.ai/code/session_01SdK2s5sJBVLc5Edhm3cZ3H