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