wtcode 0.1.0__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wtcode
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Launch your favorite code tool in a git worktree
5
5
  Author-email: Jaeho Shin <netj@sparcs.org>
6
6
  License-Expression: MIT
@@ -33,15 +33,18 @@ brew install netj/tap/wtcode
33
33
  ### PyPI (via [uv](https://docs.astral.sh/uv/))
34
34
 
35
35
  ```sh
36
- uvx wtcode
36
+ uv tool install wtcode
37
37
  ```
38
38
 
39
- Or install globally:
39
+ Or try it without installing:
40
40
 
41
41
  ```sh
42
- uv tool install wtcode
42
+ uvx wtcode
43
43
  ```
44
44
 
45
+ > **Note:** `uv tool install` is recommended over `uvx` for regular use.
46
+ > `uvx` keeps a parent `uv tool run` process alive, which can interfere with tools like tmux that detect the working directory from the process tree.
47
+
45
48
  ### From source
46
49
 
47
50
  ```sh
@@ -15,15 +15,18 @@ brew install netj/tap/wtcode
15
15
  ### PyPI (via [uv](https://docs.astral.sh/uv/))
16
16
 
17
17
  ```sh
18
- uvx wtcode
18
+ uv tool install wtcode
19
19
  ```
20
20
 
21
- Or install globally:
21
+ Or try it without installing:
22
22
 
23
23
  ```sh
24
- uv tool install wtcode
24
+ uvx wtcode
25
25
  ```
26
26
 
27
+ > **Note:** `uv tool install` is recommended over `uvx` for regular use.
28
+ > `uvx` keeps a parent `uv tool run` process alive, which can interfere with tools like tmux that detect the working directory from the process tree.
29
+
27
30
  ### From source
28
31
 
29
32
  ```sh
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "wtcode"
7
- version = "0.1.0"
7
+ version = "0.1.2"
8
8
  description = "Launch your favorite code tool in a git worktree"
9
9
  license = "MIT"
10
10
  readme = "README.md"
@@ -1,3 +1,3 @@
1
1
  """wtcode -- launch your favorite code tool in a git worktree."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.1.2"
@@ -9,13 +9,14 @@ ${WTCODE_DEBUG:+set -x}
9
9
 
10
10
  --msg() { echo "wtcode: $*" >&2; }
11
11
 
12
- WTCODE_VERSION=0.1.0
12
+ WTCODE_VERSION=0.1.2
13
13
  --version() { echo "wtcode $WTCODE_VERSION"; }
14
14
  --help() {
15
15
  cat <<USAGE
16
16
  wtcode $WTCODE_VERSION -- launch a code tool in a git worktree
17
17
 
18
18
  Usage: wtcode [BRANCH] [CMD [CMD-ARGS...]]
19
+ wtcode --exec CMD [CMD-ARGS...]
19
20
 
20
21
  BRANCH Git branch or worktree name to switch to.
21
22
  If omitted and fzf is available, interactively select one.
@@ -25,6 +26,8 @@ Usage: wtcode [BRANCH] [CMD [CMD-ARGS...]]
25
26
  CMD Command to launch in the worktree (default: \$WTCODE_CMD,
26
27
  or first available of: ${WTCODE_CMDS_TO_TRY[*]}, \$SHELL).
27
28
 
29
+ --exec Skip branch argument; select interactively, then launch CMD.
30
+
28
31
  Environment variables:
29
32
  WTCODE_CMD Default tool to launch (e.g., claude, lazygit, vim)
30
33
  WTCODE_DEBUG Enable debug tracing when set
@@ -34,6 +37,7 @@ Examples:
34
37
  wtcode feature-x # select/create worktree, launch default tool
35
38
  wtcode feature-x lazygit # launch lazygit in the worktree
36
39
  wtcode feature-x claude --resume # launch claude with --resume
40
+ wtcode --exec claude --resume # select interactively, launch claude --resume
37
41
  wtcode :new-feature # create new branch and worktree
38
42
  WTCODE_CMD=cursor wtcode feature # use cursor as the default tool
39
43
  USAGE
@@ -48,9 +52,12 @@ WTCODE_CMDS_TO_TRY=(
48
52
  )
49
53
 
50
54
  ###############################################################################
51
- ## --select-git-branch -- determine which branch/worktree to use
55
+ ## --enter-git-worktree -- select branch and create/switch worktree
52
56
  ###############################################################################
53
- --select-git-branch() {
57
+ --enter-git-worktree() {
58
+ local branch_name=
59
+
60
+ # 1. determine which branch/worktree to use
54
61
  if [[ $# -gt 0 ]]; then
55
62
  branch_name=$1; shift
56
63
  elif type fzf &>/dev/null; then
@@ -108,11 +115,14 @@ WTCODE_CMDS_TO_TRY=(
108
115
  branch_name=${1:?Need a worktree/branch name as first argument}; shift
109
116
  fi
110
117
 
111
- : ${branch_name:?non-empty worktree/branch name required}
118
+ if [[ -z ${branch_name-} ]]; then
119
+ --msg "no branch selected"
120
+ exit 1
121
+ fi
112
122
 
113
123
  # check if branch name starts with ':' to force new branch creation
114
124
  # supports multiple colons (e.g., :::my-branch) to avoid fzf matching
115
- force_new_branch=false
125
+ local force_new_branch=false
116
126
  if [[ $branch_name == :* ]]; then
117
127
  force_new_branch=true
118
128
  branch_name=${branch_name##+(:)}
@@ -128,7 +138,7 @@ WTCODE_CMDS_TO_TRY=(
128
138
  fi
129
139
 
130
140
  # check if branch_name refers to a remote branch (e.g., origin/feature-x)
131
- remote_branch=
141
+ local remote_branch=
132
142
  if ! $force_new_branch; then
133
143
  for remote in $(git remote); do
134
144
  if [[ $branch_name == "$remote/"* ]]; then
@@ -139,15 +149,8 @@ WTCODE_CMDS_TO_TRY=(
139
149
  done
140
150
  fi
141
151
 
142
- # remaining args are the command to launch
143
- wtcode_cmd=("$@")
144
- }
145
152
 
146
- ###############################################################################
147
- ## --prepare-git-worktree -- create or switch to the worktree for $branch_name
148
- ###############################################################################
149
- --prepare-git-worktree() {
150
- # determine root of the worktree dirs
153
+ # 2. create or switch to the worktree
151
154
  cd "$(git rev-parse --show-toplevel)"
152
155
  : ${GIT_WORKTREE_ROOT:=$(
153
156
  git_common_dir=$(git rev-parse --git-common-dir)
@@ -157,8 +160,7 @@ WTCODE_CMDS_TO_TRY=(
157
160
  echo "$PWD"/../"$repo_name".worktrees
158
161
  )}
159
162
 
160
- # ensure worktree based on given branch name
161
- worktree_path="$GIT_WORKTREE_ROOT"/"$branch_name"
163
+ local worktree_path="$GIT_WORKTREE_ROOT"/"$branch_name"
162
164
  if [[ -e "$worktree_path"/.git ]]; then
163
165
  --msg "using existing worktree: $worktree_path"
164
166
  elif [[ -n ${remote_branch-} ]] && ! git rev-parse --verify "refs/heads/$branch_name" &>/dev/null; then
@@ -186,17 +188,21 @@ WTCODE_CMDS_TO_TRY=(
186
188
  ## --launch-code-tool -- resolve and exec the tool in the worktree
187
189
  ###############################################################################
188
190
  --launch-code-tool() {
189
- # resolve the command to launch if not specified by user
190
- if [[ ${#wtcode_cmd[@]} -eq 0 ]]; then
191
+ # resolve the command to launch if not specified
192
+ if [[ $# -eq 0 ]]; then
191
193
  for _cmd in "${WTCODE_CMDS_TO_TRY[@]}"; do
192
- [[ -n "$_cmd" ]] && type "$_cmd" &>/dev/null && wtcode_cmd=("$_cmd") && break
194
+ [[ -n "$_cmd" ]] && type "$_cmd" &>/dev/null && set -- "$_cmd" && break
193
195
  done
194
196
  # fall back to an interactive shell
195
- wtcode_cmd=("${wtcode_cmd[@]:-${SHELL:-bash}}")
197
+ [[ $# -gt 0 ]] || set -- "${SHELL:-bash}"
196
198
  fi
197
199
 
198
- --msg "launching: ${wtcode_cmd[*]}"
199
- "${wtcode_cmd[@]}"
200
+ --msg "launching: $*"
201
+ if [[ $(type -t "$1") == function ]]; then
202
+ "$@"
203
+ else
204
+ exec "$@"
205
+ fi
200
206
  }
201
207
 
202
208
  ###############################################################################
@@ -219,7 +225,7 @@ claude() {
219
225
  }
220
226
  )
221
227
  fi
222
- exec command claude "$@"
228
+ exec claude "$@"
223
229
  }
224
230
 
225
231
  ###############################################################################
@@ -228,10 +234,18 @@ claude() {
228
234
 
229
235
  -h() { --help "$@"; }
230
236
 
237
+ --exec() {
238
+ --enter-git-worktree
239
+ --launch-code-tool "$@"
240
+ }
241
+
231
242
  --() {
232
- --select-git-branch "$@"
233
- --prepare-git-worktree
234
- --launch-code-tool
243
+ if [[ $# -gt 0 ]]; then
244
+ --enter-git-worktree "$1"; shift
245
+ else
246
+ --enter-git-worktree
247
+ fi
248
+ --launch-code-tool "$@"
235
249
  }
236
250
 
237
251
  # dispatch $1 as a function when it starts with -
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wtcode
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Launch your favorite code tool in a git worktree
5
5
  Author-email: Jaeho Shin <netj@sparcs.org>
6
6
  License-Expression: MIT
@@ -33,15 +33,18 @@ brew install netj/tap/wtcode
33
33
  ### PyPI (via [uv](https://docs.astral.sh/uv/))
34
34
 
35
35
  ```sh
36
- uvx wtcode
36
+ uv tool install wtcode
37
37
  ```
38
38
 
39
- Or install globally:
39
+ Or try it without installing:
40
40
 
41
41
  ```sh
42
- uv tool install wtcode
42
+ uvx wtcode
43
43
  ```
44
44
 
45
+ > **Note:** `uv tool install` is recommended over `uvx` for regular use.
46
+ > `uvx` keeps a parent `uv tool run` process alive, which can interfere with tools like tmux that detect the working directory from the process tree.
47
+
45
48
  ### From source
46
49
 
47
50
  ```sh
File without changes
File without changes
File without changes