handleWorktreeCommand manages git worktrees for isolated work. Usage: /worktree create - create a new worktree + branch and cd into it /worktree list - list active worktrees /worktree remove - remove a worktree /worktree status - show current worktree i
(userInput string)
| 19 | // /worktree remove <path> - remove a worktree |
| 20 | // /worktree status - show current worktree info |
| 21 | func (cli *ChatCLI) handleWorktreeCommand(userInput string) { |
| 22 | args := strings.Fields(userInput) |
| 23 | |
| 24 | if len(args) < 2 { |
| 25 | cli.worktreeStatus() |
| 26 | return |
| 27 | } |
| 28 | |
| 29 | switch args[1] { |
| 30 | case "create", "new": |
| 31 | if len(args) < 3 { |
| 32 | fmt.Println(colorize(" "+i18n.T("wt.cmd.usage_create"), ColorYellow)) |
| 33 | return |
| 34 | } |
| 35 | cli.worktreeCreate(args[2]) |
| 36 | case "list", "ls": |
| 37 | cli.worktreeList() |
| 38 | case "remove", "rm", "delete": |
| 39 | if len(args) < 3 { |
| 40 | fmt.Println(colorize(" "+i18n.T("wt.cmd.usage_remove"), ColorYellow)) |
| 41 | return |
| 42 | } |
| 43 | cli.worktreeRemove(args[2]) |
| 44 | case "status": |
| 45 | cli.worktreeStatus() |
| 46 | default: |
| 47 | // Treat as branch name: /worktree feature-x |
| 48 | cli.worktreeCreate(args[1]) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func (cli *ChatCLI) worktreeCreate(branch string) { |
| 53 | // Check if we're in a git repo |
no test coverage detected