git-workon-lib 0.1.0

API for managing worktrees
Documentation

workon

Core library for git-workon: an opinionated git worktree workflow tool.

Published on crates.io as git-workon-lib (library name: workon).

Usage

[dependencies]
git-workon-lib = "0.1"
use workon::{get_repo, get_worktrees, add_worktree, BranchType};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let repo = get_repo(None)?;

    // List all worktrees
    for wt in get_worktrees(&repo)? {
        println!("{}: {}", wt.name().unwrap_or("?"), wt.path().display());
    }

    // Create a new worktree
    let wt = add_worktree(&repo, "my-feature", BranchType::Normal, None)?;
    println!("Created worktree at {}", wt.path().display());

    Ok(())
}

API docs

Full API documentation is on docs.rs.