Add a hook command to a matcher list, creating the matcher if needed.
(
matchers: &mut Vec<GeminiHookMatcher>,
matcher_str: &str,
command: &str,
name: Option<&str>,
)
| 738 | |
| 739 | /// Add a hook command to a matcher list, creating the matcher if needed. |
| 740 | fn add_hook_to_matcher( |
| 741 | matchers: &mut Vec<GeminiHookMatcher>, |
| 742 | matcher_str: &str, |
| 743 | command: &str, |
| 744 | name: Option<&str>, |
| 745 | ) { |
| 746 | // Look for an existing matcher with the same string |
| 747 | for m in matchers.iter_mut() { |
| 748 | if m.matcher == matcher_str { |
| 749 | m.hooks.push(GeminiHookEntry { |
| 750 | hook_type: "command".to_string(), |
| 751 | command: command.to_string(), |
| 752 | name: name.map(String::from), |
| 753 | timeout: None, |
| 754 | description: None, |
| 755 | }); |
| 756 | return; |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | // Create a new matcher |
| 761 | matchers.push(GeminiHookMatcher { |
| 762 | matcher: matcher_str.to_string(), |
| 763 | hooks: vec![GeminiHookEntry { |
| 764 | hook_type: "command".to_string(), |
| 765 | command: command.to_string(), |
| 766 | name: name.map(String::from), |
| 767 | timeout: None, |
| 768 | description: None, |
| 769 | }], |
| 770 | sequential: None, |
| 771 | }); |
| 772 | } |
| 773 | |
| 774 | /// Returns `true` if a hook command string is an Atomic hook. |
| 775 | fn is_atomic_hook(command: &str) -> bool { |