limb 0.2.0

A focused CLI for git worktree management
Documentation
//! Implements `limb cd`. Prints a worktree's path for shell `eval`.

use anyhow::Result;

use crate::cli::CdArgs;
use crate::context::Context;
use crate::worktree;

/// Runs `limb cd`. Prints the selected worktree's path to stdout.
///
/// Used by shell wrappers emitted by `limb init` to implement
/// `cd "$(limb cd <name>)"`.
///
/// # Errors
///
/// Returns an error if the repo cannot be resolved or the name does not
/// match a worktree.
pub fn run(ctx: &Context, args: &CdArgs) -> Result<()> {
    let repo = ctx.repo()?;
    let w = worktree::require(&repo, &args.name)?;
    println!("{}", w.path.display());
    Ok(())
}