MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / add_hook_to_matcher

Function add_hook_to_matcher

atomic-agent/src/hooks/gemini_cli.rs:773–805  ·  view source on GitHub ↗

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>,
)

Source from the content-addressed store, hash-verified

771
772/// Add a hook command to a matcher list, creating the matcher if needed.
773fn 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.
808fn is_atomic_hook(command: &str) -> bool {

Callers 3

install_toMethod · 0.70

Calls 2

iter_mutMethod · 0.80
pushMethod · 0.45

Tested by 2