pub struct HookSpecBuilder { /* private fields */ }Expand description
Builder for HookSpec.
Implementations§
Source§impl HookSpecBuilder
impl HookSpecBuilder
Sourcepub fn command_program<I, S>(self, program: impl Into<String>, args: I) -> Self
pub fn command_program<I, S>(self, program: impl Into<String>, args: I) -> Self
Set the program and arguments the harness should execute when the hook fires.
Integrations that only accept shell strings render this command with POSIX shell quoting, so arguments containing spaces or shell metacharacters remain arguments instead of becoming shell syntax.
Sourcepub fn command_shell_unchecked(self, command: impl Into<String>) -> Self
pub fn command_shell_unchecked(self, command: impl Into<String>) -> Self
Set an unchecked raw shell command.
This is intentionally explicit: the command string is passed through as shell syntax for harnesses and generated scripts. Use this only when the full command is trusted and already sanitized.
Sourcepub fn rules(self, content: impl Into<String>) -> Self
pub fn rules(self, content: impl Into<String>) -> Self
Attach a markdown rules block to be injected into the harness’s memory file.
Sourcepub fn script(self, script: ScriptTemplate) -> Self
pub fn script(self, script: ScriptTemplate) -> Self
Attach a script template (shell or TS) for harnesses that need one.
Sourcepub fn friendly_name(self, name: impl Into<String>) -> Self
pub fn friendly_name(self, name: impl Into<String>) -> Self
Set a human-friendly display name shown in install reports.
Sourcepub fn build(self) -> HookSpec
pub fn build(self) -> HookSpec
Finalize the spec, panicking on missing or invalid fields.
Convenience wrapper around try_build() for tests
and examples. Production code should prefer try_build()
to propagate errors instead of panicking.
§Panics
Panics if command was never set.
Sourcepub fn try_build(self) -> Result<HookSpec, AgentConfigError>
pub fn try_build(self) -> Result<HookSpec, AgentConfigError>
Finalize the spec, returning Result on missing or invalid fields.
This is the recommended way to build a spec in production code. See crate-level documentation for a full example.
§Errors
AgentConfigError::InvalidTagwhentag, the matcher string, or any custom event name fails identifier or hook-string validation.AgentConfigError::MissingSpecField(field = "command") when neitherHookSpecBuilder::command_programnorHookSpecBuilder::command_shell_uncheckedwas called.AgentConfigError::InvalidTagfromcommand.validate()when the command string is empty or contains control characters.
Trait Implementations§
Source§impl Clone for HookSpecBuilder
impl Clone for HookSpecBuilder
Source§fn clone(&self) -> HookSpecBuilder
fn clone(&self) -> HookSpecBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more