pub struct ClaudeBuilder { /* private fields */ }Expand description
Implementations§
Source§impl ClaudeBuilder
impl ClaudeBuilder
Sourcepub fn binary(self, path: impl Into<PathBuf>) -> Self
pub fn binary(self, path: impl Into<PathBuf>) -> Self
Set the path to the claude binary.
If not set, the binary is resolved from PATH using which.
Sourcepub fn working_dir(self, path: impl Into<PathBuf>) -> Self
pub fn working_dir(self, path: impl Into<PathBuf>) -> Self
Set the working directory for all commands.
The spawned process will use this as its current directory.
Sourcepub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add an environment variable to pass to all commands.
Sourcepub fn envs(
self,
vars: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
) -> Self
pub fn envs( self, vars: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>, ) -> Self
Add multiple environment variables.
Sourcepub fn timeout_secs(self, seconds: u64) -> Self
pub fn timeout_secs(self, seconds: u64) -> Self
Set a default timeout for all commands (in seconds).
Sourcepub fn arg(self, arg: impl Into<String>) -> Self
pub fn arg(self, arg: impl Into<String>) -> Self
Add a global argument applied to all commands.
This is an escape hatch for flags not yet covered by the API.
Sourcepub fn retry(self, policy: RetryPolicy) -> Self
pub fn retry(self, policy: RetryPolicy) -> Self
Set a default retry policy for all commands.
Individual commands can override this via their own retry settings.
§Example
use claude_wrapper::{Claude, RetryPolicy};
use std::time::Duration;
let claude = Claude::builder()
.retry(RetryPolicy::new()
.max_attempts(3)
.initial_backoff(Duration::from_secs(2))
.exponential()
.retry_on_timeout(true))
.build()?;Sourcepub fn tested_cli_version_range(self, min: CliVersion, max: CliVersion) -> Self
pub fn tested_cli_version_range(self, min: CliVersion, max: CliVersion) -> Self
Declare the inclusive [min, max] range of claude CLI
versions this client has been tested against.
The wrapper does not enforce the range – nothing errors when
it’s set wrong. Use Claude::cli_version_status (or its
sync mirror) at startup to classify the actually-installed CLI
against this declaration; that call returns a typed
CliVersionStatus AND emits a tracing::warn! when
outside the range. Hosts (claude-server, application code)
can additionally surface the status to operators.
§Why this exists
CLI semantics drift across minor / patch releases (e.g.
claude agents was repurposed in 2.1.143). The min floor
lets us say “we know it’s broken below this”; the max ceiling
lets us say “we haven’t verified above this – proceed but
expect surprises.”
§Example
use claude_wrapper::{Claude, CliVersion};
let claude = Claude::builder()
.tested_cli_version_range(CliVersion::new(2, 1, 0), CliVersion::new(2, 1, 999))
.build()?;
// Run once at startup to log a warning if the CLI is out of range.
let _status = claude.cli_version_status().await?;