| 5642 | } |
| 5643 | |
| 5644 | static int cbm_upsert_factory_hooks(const char *settings_path, const char *binary_path) { |
| 5645 | char command[CLI_BUF_8K]; |
| 5646 | char released_command[CLI_BUF_8K]; |
| 5647 | if (cbm_build_augment_dialect_command(binary_path, "factory", command, sizeof(command)) != |
| 5648 | CLI_OK || |
| 5649 | cbm_build_augment_command(binary_path, released_command, sizeof(released_command)) != |
| 5650 | CLI_OK) { |
| 5651 | return CLI_ERR; |
| 5652 | } |
| 5653 | const char *const old_commands[] = {released_command, NULL}; |
| 5654 | int session_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 5655 | .settings_path = settings_path, |
| 5656 | .hook_event = "SessionStart", |
| 5657 | .matcher_str = NULL, |
| 5658 | .command_str = command, |
| 5659 | .old_commands = old_commands, |
| 5660 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5661 | .match_command_exact = command, |
| 5662 | }); |
| 5663 | int read_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 5664 | .settings_path = settings_path, |
| 5665 | .hook_event = "PostToolUse", |
| 5666 | .matcher_str = "Read", |
| 5667 | .command_str = command, |
| 5668 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5669 | .match_command_exact = command, |
| 5670 | }); |
| 5671 | return session_result == CLI_OK && read_result == CLI_OK ? CLI_OK : CLI_ERR; |
| 5672 | } |
| 5673 | |
| 5674 | static int cbm_remove_factory_hooks(const char *settings_path, const char *binary_path) { |
| 5675 | char command[CLI_BUF_8K]; |
no test coverage detected