treeboot-core 0.7.0

Reusable worktree bootstrap engine for the treeboot CLI.
Documentation

treeboot-core

Reusable Rust library for bootstrapping Git worktrees from a repo-local treeboot setup contract.

crates.io docs.rs License

This crate contains the public API used by the treeboot CLI. It handles Git worktree discovery, init script discovery, declarative config parsing, validation, action planning, file operation execution, command execution, and structured output events.

This crate exposes the same workflow as typed Rust APIs for callers that want to embed treeboot behavior directly.

API Shape

Use command-shaped facade functions when you want the same behavior as the CLI:

use treeboot_core::{EnvironmentInput, RunOptions, Reporter, run};

fn bootstrap(reporter: &mut dyn Reporter) -> treeboot_core::Result<()> {
    let report = run(
        RunOptions {
            environment: EnvironmentInput::from_process_env(),
            ..RunOptions::default()
        },
        reporter,
    )?;
    let _ = report;

    Ok(())
}

RunOptions::default() and the other command-shaped option defaults are environment-pure. Pass EnvironmentInput::from_process_env() when embedding the CLI's process-environment compatibility behavior.

Use lower-level types when embedding pieces of the workflow. Action plans are validated values: build them through constructors, then inspect them through accessor methods before execution if needed.

use std::path::Path;

use treeboot_core::{ActionPlan, ActionPlanOptions, Config, Worktree};

fn plan_bootstrap(
    config_path: &Path,
    context: &Worktree,
    config: &Config,
) -> treeboot_core::Result<ActionPlan> {
    let plan = ActionPlan::from_manifest(
        config_path,
        config,
        context,
        ActionPlanOptions::default(),
    )?;
    let _file_count = plan.files().len();

    Ok(plan)
}

The crate exposes typed errors through treeboot_core::Error and avoids CLI-specific dependencies.

Relationship to treeboot

treeboot-core is the reusable library crate. The treeboot package provides the command-line interface and user-facing reporting on top of this API.

See the repository for project details.

License

MIT