From 3d2208f432f8b4f4caa2cc0cf4f8fbff20947352 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Tue, 24 Nov 2026 10:33:11 +0100 Subject: [PATCH] pinwheel: Add `wt --help` and reject unknown `wt` options An unknown option such as `-b` or `--help` was taken as a branch name and passed on to `git worktree add`, which read it as its own option: `--help` printed git's usage and `-b` failed asking for a value. `wt` now prints its own usage for `-h`/`--help`, moved there from the comment at the top of the file, and rejects any other option. --- hosts/pinwheel/modules/work/wt.zsh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/hosts/pinwheel/modules/work/wt.zsh b/hosts/pinwheel/modules/work/wt.zsh index dc38e9b..4e05cd8 100644 --- a/hosts/pinwheel/modules/work/wt.zsh +++ b/hosts/pinwheel/modules/work/wt.zsh @@ -1,14 +1,19 @@ # Git worktrees beside the primary checkout, one per branch: ~/code/work/backend's live in # ~/code/work/backend.worktrees/. -# -# wt list worktrees -# wt cd to the worktree that has , adding one if none has it -# wt -c new branch off main, tracked by gt, in a new worktree; make its first -# commit with `gt modify -a`, since `gt create` would stack a second branch -# wt rm [] remove 's worktree, or the current one; the branch stays -# wt sync [] gt sync in the primary checkout, then gt restack in every worktree -# not on main whose PR is not merged wt() { + if [[ $1 == -h || $1 == --help ]]; then + print -rl -- \ + 'usage: wt list worktrees' \ + ' wt cd to the worktree that has , adding one if none has it' \ + ' wt -c new branch off main, tracked by gt, in a new worktree; make its' \ + ' first commit with `gt modify -a`, since `gt create` would stack' \ + ' a second branch' \ + " wt rm [] remove 's worktree, or the current one; the branch stays" \ + ' wt sync [] gt sync in the primary checkout, then gt restack in every' \ + ' worktree not on main whose PR is not merged' + return + fi + local primary dir primary=$(git rev-parse --path-format=absolute --git-common-dir) || return primary=${primary:h} @@ -66,6 +71,10 @@ wt() { _wt_setup "$primary" "$dir" && cd "$dir" ;; + -*) + print -u2 "wt: unknown option $1, see wt --help" + return 2 + ;; *) dir=$(_wt_dir "$1") if [[ -z $dir ]]; then