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:740–772  ·  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

738
739/// Add a hook command to a matcher list, creating the matcher if needed.
740fn 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.
775fn is_atomic_hook(command: &str) -> bool {

Callers 3

install_toMethod · 0.70

Calls 2

iter_mutMethod · 0.80
pushMethod · 0.45

Tested by 2