gwx 2.2.1

A friendly git worktree manager with automatic paths, hooks and shell integration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! `gwx cd` — move into a worktree.
//!
//! With no argument this goes to the main worktree, mirroring how a bare `cd`
//! takes you home. Choosing from a list is `gwx list`.

use anyhow::Result;

use crate::cd_target;
use crate::cli::CdArgs;
use crate::repo::Repo;

pub fn run(args: CdArgs) -> Result<()> {
    let repo = Repo::discover()?;
    let worktree = repo.resolve(args.name.as_deref())?;
    cd_target::request(&worktree.path)
}