| 10 | ) |
| 11 | |
| 12 | func (cli *ChatCLI) handleHooksCommand(userInput string) { |
| 13 | if cli.hookManager == nil { |
| 14 | fmt.Println(colorize(" "+i18n.T("hooks.cmd.not_initialized"), ColorYellow)) |
| 15 | return |
| 16 | } |
| 17 | |
| 18 | hks := cli.hookManager.GetHooks() |
| 19 | |
| 20 | fmt.Println() |
| 21 | fmt.Println(uiBox("⚡", i18n.T("hooks.cmd.box_title"), ColorPurple)) |
| 22 | p := uiPrefix(ColorPurple) |
| 23 | |
| 24 | if len(hks) == 0 { |
| 25 | fmt.Println(p + colorize(i18n.T("hooks.cmd.none_configured"), ColorGray)) |
| 26 | fmt.Println(p) |
| 27 | fmt.Println(p + colorize(i18n.T("hooks.cmd.configure_in"), ColorGray)) |
| 28 | fmt.Println(p) |
| 29 | fmt.Println(p + colorize(` { "hooks": [{`, ColorGray)) |
| 30 | fmt.Println(p + colorize(` "name": "notify-tool",`, ColorGray)) |
| 31 | fmt.Println(p + colorize(` "event": "PostToolUse",`, ColorGray)) |
| 32 | fmt.Println(p + colorize(` "type": "command",`, ColorGray)) |
| 33 | fmt.Println(p + colorize(` "command": "echo \"Tool $CHATCLI_HOOK_TOOL done\""`, ColorGray)) |
| 34 | fmt.Println(p + colorize(` }]}`, ColorGray)) |
| 35 | fmt.Println(p) |
| 36 | fmt.Println(p + colorize(i18n.T("hooks.cmd.events_label"), ColorCyan)) |
| 37 | for _, evt := range hooks.AllEventTypes { |
| 38 | fmt.Println(p + " " + colorize(string(evt), ColorGray)) |
| 39 | } |
| 40 | fmt.Println(p) |
| 41 | fmt.Println(uiBoxEnd(ColorPurple)) |
| 42 | fmt.Println() |
| 43 | return |
| 44 | } |
| 45 | |
| 46 | for _, h := range hks { |
| 47 | icon := "●" |
| 48 | statusColor := ColorGreen |
| 49 | if !h.IsEnabled() { |
| 50 | icon = "○" |
| 51 | statusColor = ColorGray |
| 52 | } |
| 53 | |
| 54 | target := h.Command |
| 55 | if h.Type == "http" { |
| 56 | target = h.URL |
| 57 | } |
| 58 | |
| 59 | fmt.Println(p + fmt.Sprintf(" %s%s%s %s%s%s", |
| 60 | statusColor, icon, ColorReset, |
| 61 | ColorBold, h.Name, ColorReset)) |
| 62 | fmt.Println(p + fmt.Sprintf(" %s%s%s %s %s%s%s %s", |
| 63 | ColorGray, i18n.T("hooks.cmd.event_label"), ColorReset, string(h.Event), |
| 64 | ColorGray, i18n.T("hooks.cmd.type_label"), ColorReset, string(h.Type))) |
| 65 | fmt.Println(p + fmt.Sprintf(" %s%s%s %s", |
| 66 | ColorGray, i18n.T("hooks.cmd.target_label"), ColorReset, colorize(target, ColorGray))) |
| 67 | if h.ToolPattern != "" { |
| 68 | fmt.Println(p + fmt.Sprintf(" %s%s%s %s", |
| 69 | ColorGray, i18n.T("hooks.cmd.filter_label"), ColorReset, colorize(h.ToolPattern, ColorCyan))) |