MCPcopy Create free account
hub / github.com/diillson/chatcli / handleWorktreeCommand

Method handleWorktreeCommand

cli/worktree.go:21–50  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

19// /worktree remove <path> - remove a worktree
20// /worktree status - show current worktree info
21func (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
52func (cli *ChatCLI) worktreeCreate(branch string) {
53 // Check if we're in a git repo

Callers 1

buildRoutesMethod · 0.80

Calls 6

worktreeStatusMethod · 0.95
worktreeCreateMethod · 0.95
worktreeListMethod · 0.95
worktreeRemoveMethod · 0.95
TFunction · 0.92
colorizeFunction · 0.85

Tested by

no test coverage detected