load_hook_configs

Function load_hook_configs 

Source
pub fn load_hook_configs(
    hooks_dir: &Path,
) -> Result<HashMap<String, HookConfig>>
Expand description

Load hook configurations from a directory containing JSON files.

Scans the specified directory for .json files and parses each one as a HookConfig. The filename (without extension) becomes the hook name in the returned map.

§Arguments

  • hooks_dir - Directory path containing hook JSON configuration files

§Returns

A HashMap mapping hook names to their configurations. If the directory doesn’t exist, returns an empty map.

§Errors

Returns an error if:

  • Directory reading fails due to permissions or I/O errors
  • Any JSON file cannot be read or parsed
  • A filename is invalid or cannot be converted to a string

§Examples

use agpm_cli::hooks::load_hook_configs;
use std::path::Path;

let hooks_dir = Path::new(".claude/hooks");
let configs = load_hook_configs(hooks_dir)?;

for (name, config) in configs {
    println!("Loaded hook '{}' with {} events", name, config.events.len());
}