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:774–806  ·  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

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

Callers 3

install_toMethod · 0.70

Calls 2

iter_mutMethod · 0.80
pushMethod · 0.45

Tested by 2