| 1 | package cli |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | |
| 7 | "reasonix/internal/hook" |
| 8 | ) |
| 9 | |
| 10 | func renderHooks(width int, hooks []hook.ResolvedHook) string { |
| 11 | var b strings.Builder |
| 12 | fmt.Fprintf(&b, "%s\n", viewHeader("hooks (%d active)", len(hooks))) |
| 13 | for _, h := range hooks { |
| 14 | match := h.Match |
| 15 | if h.Event == hook.PreToolUse || h.Event == hook.PostToolUse || h.Event == hook.PermissionRequest { |
| 16 | if match == "" { |
| 17 | match = "*" |
| 18 | } |
| 19 | } else { |
| 20 | match = "-" |
| 21 | } |
| 22 | used := 2 + viewPadWidth(string(h.Event), 16) + 1 + 8 + 1 + 8 + 1 |
| 23 | fmt.Fprintf(&b, " %-16s %s %s %s\n", |
| 24 | h.Event, viewMeta(fmt.Sprintf("%-8s", h.Scope)), viewMeta(fmt.Sprintf("%-8s", match)), viewCompactText(h.Command, viewBudget(width, used))) |
| 25 | } |
| 26 | b.WriteByte('\n') |
| 27 | b.WriteString(viewHint(viewCompactText("config: project .reasonix/settings.json + global <Reasonix home>/settings.json", viewBudget(width, 2)))) |
| 28 | return strings.TrimRight(b.String(), "\n") |
| 29 | } |
| 30 |