Install all hook definitions into a `ClaudeHooks` struct. Returns the number of newly installed hooks.
(hooks: &mut ClaudeHooks, _settings_path: &Path)
| 208 | /// |
| 209 | /// Returns the number of newly installed hooks. |
| 210 | fn install_hooks_into(hooks: &mut ClaudeHooks, _settings_path: &Path) -> AgentResult<usize> { |
| 211 | let mut count = 0; |
| 212 | for (_label, matcher, verb) in HOOK_DEFS { |
| 213 | let command = |
| 214 | crate::hooks::guarded_hook_command(&format!("{} {}", ATOMIC_HOOK_PREFIX, verb)); |
| 215 | |
| 216 | let matchers = match *verb { |
| 217 | "session-start" => &mut hooks.session_start, |
| 218 | "session-end" => &mut hooks.session_end, |
| 219 | "stop" => &mut hooks.stop, |
| 220 | "user-prompt-submit" => &mut hooks.user_prompt_submit, |
| 221 | "pre-task" => &mut hooks.pre_tool_use, |
| 222 | "post-task" | "post-todo" | "post-tool" => &mut hooks.post_tool_use, |
| 223 | _ => continue, |
| 224 | }; |
| 225 | |
| 226 | if !settings::hook_command_exists(matchers, matcher, &command) { |
| 227 | settings::add_hook_to_matcher(matchers, matcher, &command); |
| 228 | count += 1; |
| 229 | } |
| 230 | } |
| 231 | Ok(count) |
| 232 | } |
no test coverage detected