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>,
)
| 771 | |
| 772 | /// Add a hook command to a matcher list, creating the matcher if needed. |
| 773 | fn add_hook_to_matcher( |
| 774 | matchers: &mut Vec<GeminiHookMatcher>, |
| 775 | matcher_str: &str, |
| 776 | command: &str, |
| 777 | name: Option<&str>, |
| 778 | ) { |
| 779 | // Look for an existing matcher with the same string |
| 780 | for m in matchers.iter_mut() { |
| 781 | if m.matcher == matcher_str { |
| 782 | m.hooks.push(GeminiHookEntry { |
| 783 | hook_type: "command".to_string(), |
| 784 | command: command.to_string(), |
| 785 | name: name.map(String::from), |
| 786 | timeout: None, |
| 787 | description: None, |
| 788 | }); |
| 789 | return; |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | // Create a new matcher |
| 794 | matchers.push(GeminiHookMatcher { |
| 795 | matcher: matcher_str.to_string(), |
| 796 | hooks: vec![GeminiHookEntry { |
| 797 | hook_type: "command".to_string(), |
| 798 | command: command.to_string(), |
| 799 | name: name.map(String::from), |
| 800 | timeout: None, |
| 801 | description: None, |
| 802 | }], |
| 803 | sequential: None, |
| 804 | }); |
| 805 | } |
| 806 | |
| 807 | /// Returns `true` if a hook command string is an Atomic hook. |
| 808 | fn is_atomic_hook(command: &str) -> bool { |