| 5725 | } |
| 5726 | |
| 5727 | static int cbm_upsert_factory_hooks(const char *settings_path, const char *binary_path) { |
| 5728 | char command[CLI_BUF_8K]; |
| 5729 | char released_command[CLI_BUF_8K]; |
| 5730 | if (cbm_build_augment_dialect_command(binary_path, "factory", command, sizeof(command)) != |
| 5731 | CLI_OK || |
| 5732 | cbm_build_augment_command(binary_path, released_command, sizeof(released_command)) != |
| 5733 | CLI_OK) { |
| 5734 | return CLI_ERR; |
| 5735 | } |
| 5736 | const char *const old_commands[] = {released_command, NULL}; |
| 5737 | int session_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 5738 | .settings_path = settings_path, |
| 5739 | .hook_event = "SessionStart", |
| 5740 | .matcher_str = NULL, |
| 5741 | .command_str = command, |
| 5742 | .old_commands = old_commands, |
| 5743 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5744 | .match_command_exact = command, |
| 5745 | }); |
| 5746 | int read_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 5747 | .settings_path = settings_path, |
| 5748 | .hook_event = "PostToolUse", |
| 5749 | .matcher_str = "Read", |
| 5750 | .command_str = command, |
| 5751 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5752 | .match_command_exact = command, |
| 5753 | }); |
| 5754 | return session_result == CLI_OK && read_result == CLI_OK ? CLI_OK : CLI_ERR; |
| 5755 | } |
| 5756 | |
| 5757 | static int cbm_remove_factory_hooks(const char *settings_path, const char *binary_path) { |
| 5758 | char command[CLI_BUF_8K]; |
no test coverage detected