Summary
Add a new command dgr switch that provides both direct branch switching and an interactive tree-based branch selection UI.
User Stories
- As a developer, I want to quickly switch between branches in my stack so that I can work on different parts of a feature without typing long branch names.
- As a developer, I want to see a visual tree of my branches when switching so that I understand the context of the branch I am switching to.
Acceptance Criteria
Implementation Notes
- UI Framework: Use
ratatui for the interactive TUI.
- Branch Data: Leverage
crate::core::tree::run(&TreeOptions::default()) to get the TreeView.
- Tree Rendering: Flatten the
TreeView into a list for easier selection management while maintaining indentation levels.
- Git Integration: Use
crate::core::git::switch_branch(branch_name) for the actual switch.
- CLI Structure:
- Add
switch to src/cli/mod.rs.
- Create
src/cli/switch/mod.rs for command handling.
- Create
src/cli/switch/interactive.rs for TUI logic.
Summary
Add a new command
dgr switchthat provides both direct branch switching and an interactive tree-based branch selection UI.User Stories
Acceptance Criteria
dgr switchenters interactive mode if no branch is specified.->.hjklnavigate the selection.Enterswitches to the selected branch and prints a confirmation message.Escorqexits interactive mode without switching.dgr switch <branch>switches directly to<branch>if it exists.Implementation Notes
ratatuifor the interactive TUI.crate::core::tree::run(&TreeOptions::default())to get theTreeView.TreeViewinto a list for easier selection management while maintaining indentation levels.crate::core::git::switch_branch(branch_name)for the actual switch.switchtosrc/cli/mod.rs.src/cli/switch/mod.rsfor command handling.src/cli/switch/interactive.rsfor TUI logic.