treeflow 0.2.0

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

#[cfg(test)]
mod worktype_tests {
    use tempdir::TempDir;
    use crate::utils::treeflow_command::TreeflowCommand;

    #[test]
    fn add_work_types_and_then_remove_one() {
        let config_dir = TempDir::new("config_dir").expect("Temp dir");
        let current_dir = TempDir::new("current_dir").expect("Temp dir");

        // Add two work types first
        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_add("feature", "feature/user/")
            .current_dir(current_dir.path())
            .cmd()
            .assert()
            .success();

        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_add("bugfix", "bugfix/user/")
            .current_dir(current_dir.path())
            .cmd()
            .assert()
            .success();

        // Verify both are there
        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_list()
            .cmd()
            .assert()
            .success()
            .stdout("feature    feature/user/\nbugfix    bugfix/user/\n");

        // Remove one work type
        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_remove("bugfix")
            .current_dir(current_dir.path())
            .cmd()
            .assert()
            .success();

        // Verify only one remains
        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_list()
            .cmd()
            .assert()
            .success()
            .stdout("feature    feature/user/\n");
    }

    #[test]
    fn list_multiple_work_types() {
        let config_dir = TempDir::new("config_dir").expect("Temp dir");
        let current_dir = TempDir::new("current_dir").expect("Temp dir");

        // Add work types with complex prefixes
        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_add("feature", "feature/user/feature-name/")
            .current_dir(current_dir.path())
            .cmd()
            .assert()
            .success();

        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_add("release", "release/v1.2.3/")
            .current_dir(current_dir.path())
            .cmd()
            .assert()
            .success();

        // Verify complex prefixes are displayed correctly
        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_list()
            .cmd()
            .assert()
            .success()
            .stdout("feature    feature/user/feature-name/\nrelease    release/v1.2.3/\n");
    }

    #[test]
    fn remove_work_type_updates_list() {
        let config_dir = TempDir::new("config_dir").expect("Temp dir");
        let current_dir = TempDir::new("current_dir").expect("Temp dir");

        // Add multiple work types
        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_add("feature", "feature/")
            .current_dir(current_dir.path())
            .cmd()
            .assert()
            .success();

        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_add("bugfix", "bugfix/")
            .current_dir(current_dir.path())
            .cmd()
            .assert()
            .success();

        // Remove one work type
        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_remove("bugfix")
            .current_dir(current_dir.path())
            .cmd()
            .assert()
            .success();

        // Verify only remaining work type is listed
        TreeflowCommand::new(config_dir.path().to_path_buf())
            .worktype_list()
            .cmd()
            .assert()
            .success()
            .stdout("feature    feature/\n");
    }
}