Install all hook definitions into a `ClaudeHooks` struct. Returns the number of newly installed hooks.
(hooks: &mut ClaudeHooks, _settings_path: &Path)
| 328 | /// |
| 329 | /// Returns the number of newly installed hooks. |
| 330 | fn install_hooks_into(hooks: &mut ClaudeHooks, _settings_path: &Path) -> AgentResult<usize> { |
| 331 | let mut count = 0; |
| 332 | for (_label, matcher, verb) in HOOK_DEFS { |
| 333 | let command = |
| 334 | crate::hooks::guarded_hook_command(&format!("{} {}", ATOMIC_HOOK_PREFIX, verb)); |
| 335 | |
| 336 | let matchers = match *verb { |
| 337 | "session-start" => &mut hooks.session_start, |
| 338 | "session-end" => &mut hooks.session_end, |
| 339 | "stop" => &mut hooks.stop, |
| 340 | "user-prompt-submit" => &mut hooks.user_prompt_submit, |
| 341 | "pre-task" => &mut hooks.pre_tool_use, |
| 342 | "post-task" | "post-todo" | "post-tool" => &mut hooks.post_tool_use, |
| 343 | _ => continue, |
| 344 | }; |
| 345 | |
| 346 | if !settings::hook_command_exists(matchers, matcher, &command) { |
| 347 | settings::add_hook_to_matcher(matchers, matcher, &command); |
| 348 | count += 1; |
| 349 | } |
| 350 | } |
| 351 | Ok(count) |
| 352 | } |
no test coverage detected