Module cli

Module cli 

Source
Expand description

Builder pattern for configuring and launching the Claude CLI process.

This module provides ClaudeCliBuilder for constructing Claude CLI commands with the correct flags for JSON streaming mode. The builder automatically configures:

  • JSON streaming input/output formats
  • Non-interactive print mode
  • Verbose output for proper streaming
  • OAuth token and API key environment variables for authentication

§Example

use claude_codes::ClaudeCliBuilder;

// Build and spawn an async Claude process
let child = ClaudeCliBuilder::new()
    .model("sonnet")
    .session_id(uuid::Uuid::new_v4())
    .spawn().await?;
     
// With OAuth authentication
let child = ClaudeCliBuilder::new()
    .model("opus")
    .oauth_token("sk-ant-oat-123456789")
    .spawn_sync()?;

// Or with API key authentication
let child = ClaudeCliBuilder::new()
    .api_key("sk-ant-api-987654321")
    .spawn_sync()?;

Structs§

ClaudeCliBuilder
Builder for creating Claude CLI commands in JSON streaming mode

Enums§

PermissionMode
Permission mode for Claude CLI