treeflow 0.2.1

CLI tool for simplified Git worktree management to speed up switching contexts when working collaboratively.
Documentation
#[cfg(test)]
mod utils;

#[cfg(test)]
mod primary_tests {
    use tempdir::TempDir;
    use predicates::prelude::*;
    use treeflow::utils::Return;
    use crate::utils::treeflow_command::TreeflowCommand;

    #[test]
    fn navigates_to_repository() {
        let config_dir = TempDir::new("config_dir").expect("should be able to create temp config dir");
        let repository_dir = TempDir::new("repository_dir").expect("should be able to create temp repository dir");
        let worktrees_dir = TempDir::new("worktrees_dir").expect("should be able to create temp worktrees dir");

        // Convert TempDir to PathBuf once at the top
        let config_dir_buf = config_dir.path().to_path_buf();
        let repository_dir_buf = repository_dir.path().to_path_buf();
        let worktrees_dir_buf = worktrees_dir.path().to_path_buf();

        let specific_worktree_dir = worktrees_dir_buf.join("feature/test");

        // Create the directory for a specific worktree
        std::fs::create_dir_all(&specific_worktree_dir).expect("should be able to create worktree dir");

        // Add project to config
        TreeflowCommand::new(config_dir_buf.clone())
            .project_add(&repository_dir_buf, Some(&worktrees_dir_buf))
            .current_dir(&repository_dir_buf)
            .cmd()
            .assert()
            .success();

        // Run primary command when in a worktree's directory
        TreeflowCommand::new(config_dir_buf)
            .current_dir(&specific_worktree_dir)
            .primary()
            .cmd()
            .assert()
            .success()
            .stdout(Return::Cd { path: repository_dir_buf }.print());
    }

    #[test]
    fn fails_when_not_in_project() {
        let config_dir = TempDir::new("config_dir").expect("should be able to create temp config dir");
        let outside_dir = TempDir::new("outside_dir").expect("should be able to create temp outside dir");

        let outside_dir_buf = outside_dir.path().to_path_buf();

        TreeflowCommand::new(config_dir.path().to_path_buf())
            .primary()
            .current_dir(&outside_dir_buf)
            .cmd()
            .assert()
            .failure()
            .stderr(predicate::str::contains("not found").and(predicate::str::contains(outside_dir_buf.display().to_string())));
    }
}