Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Feat: Add summary and styling to `configure-shell` and `list`
Maximilian Roos500d39ee316a
diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rsindex 659db80b5..61739b52e 100644--- a/src/commands/configure_shell.rs+++ b/src/commands/configure_shell.rs@@ -333,10 +333,13 @@ fn configure_fish_file(}fn prompt_for_confirmation(results: &[ConfigureResult]) -> Result<bool, String> {- use anstyle::Style;+ use anstyle::{AnsiColor, Color, Style};++ let cyan = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan)));+ let cyan_bold = cyan.bold();eprintln!();- eprintln!("The following changes will be made:");+ eprintln!("π§ {cyan_bold}Configuration changes:{cyan_bold:#}");eprintln!();for result in results {@@ -362,7 +365,7 @@ fn prompt_for_confirmation(results: &[ConfigureResult]) -> Result<bool, String>}eprintln!();- eprint!("Proceed? [y/N] ");+ eprint!("π‘ Proceed? [y/N] ");io::stderr().flush().map_err(|e| e.to_string())?;let mut input = String::new();diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rsindex 66a951508..806490cd1 100644--- a/src/commands/list/mod.rs+++ b/src/commands/list/mod.rs@@ -6,7 +6,7 @@ mod spacing_test;use rayon::prelude::*;use worktrunk::git::{GitError, Repository};-use worktrunk::styling::{WARNING, WARNING_EMOJI, eprintln};+use worktrunk::styling::{HINT, HINT_EMOJI, WARNING, WARNING_EMOJI, eprintln};use layout::calculate_responsive_layout;use render::{format_header_line, format_list_item_line};@@ -272,7 +272,10 @@ pub fn handle_list(format: crate::OutputFormat, show_branches: bool) -> Result<(Err(e) => {let warning_bold = WARNING.bold();eprintln!(- "{WARNING_EMOJI} Failed to enrich branch {warning_bold}{branch}{warning_bold:#}: {e}"+ "{WARNING_EMOJI} {WARNING}Failed to enrich branch {warning_bold}{branch}{warning_bold:#}: {e}{WARNING:#}"+ );+ eprintln!(+ "{HINT_EMOJI} {HINT}This branch will be shown with limited information{HINT:#}");}}@@ -307,8 +310,72 @@ pub fn handle_list(format: crate::OutputFormat, show_branches: bool) -> Result<(for item in &items {format_list_item_line(item, &layout, current_worktree_path.as_ref());}++ // Display summary line+ display_summary(&items, show_branches);}}Ok(())}++fn display_summary(items: &[ListItem], include_branches: bool) {+ use anstyle::Style;+ use worktrunk::styling::println;++ if items.is_empty() {+ println!();+ use worktrunk::styling::{HINT, HINT_EMOJI};+ println!("{HINT_EMOJI} {HINT}No worktrees found{HINT:#}");+ println!("{HINT_EMOJI} {HINT}Create one with: wt switch --create <branch>{HINT:#}");+ return;+ }++ let worktree_count = items.iter().filter(|i| i.worktree_info().is_some()).count();+ let branch_count = items.len() - worktree_count;++ // Count worktrees with changes+ let dirty_count = items+ .iter()+ .filter_map(|i| i.worktree_info())+ .filter(|wt| {+ let (added, deleted) = wt.working_tree_diff;+ added > 0 || deleted > 0+ })+ .count();++ // Count items ahead/behind+ let ahead_count = items.iter().filter(|i| i.ahead() > 0).count();+ let behind_count = items.iter().filter(|i| i.behind() > 0).count();++ println!();+ let dim = Style::new().dimmed();++ // Build summary parts+ let mut parts = Vec::new();++ if include_branches {+ parts.push(format!("{} worktrees", worktree_count));+ if branch_count > 0 {+ parts.push(format!("{} branches", branch_count));+ }+ } else {+ let plural = if worktree_count == 1 { "" } else { "s" };+ parts.push(format!("{} worktree{}", worktree_count, plural));+ }++ if dirty_count > 0 {+ parts.push(format!("{} with changes", dirty_count));+ }++ if ahead_count > 0 {+ parts.push(format!("{} ahead", ahead_count));+ }++ if behind_count > 0 {+ parts.push(format!("{} behind", behind_count));+ }++ let summary = parts.join(", ");+ println!("{dim}Showing {summary}{dim:#}");+}diff --git a/src/commands/mod.rs b/src/commands/mod.rsindex d9aa2fed8..a7c0623af 100644--- a/src/commands/mod.rs+++ b/src/commands/mod.rs@@ -6,7 +6,7 @@ pub mod merge;pub mod worktree;pub use completion::{handle_complete, handle_completion};-pub use configure_shell::handle_configure_shell;+pub use configure_shell::{ConfigAction, handle_configure_shell};pub use init::handle_init;pub use list::handle_list;pub use merge::handle_merge;diff --git a/src/main.rs b/src/main.rsindex a8e60f96d..e1ae20df4 100644--- a/src/main.rs+++ b/src/main.rs@@ -155,7 +155,24 @@ fn main() {Commands::ConfigureShell { shell, cmd, yes } => {handle_configure_shell(shell, &cmd, yes).map(|results| {- for result in results {+ use anstyle::{AnsiColor, Color};++ // Count actual changes (not AlreadyExists)+ let changes_count = results+ .iter()+ .filter(|r| !matches!(r.action, crate::ConfigAction::AlreadyExists))+ .count();++ if changes_count == 0 {+ // All shells already configured+ let green = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green)));+ let green_bold = green.bold();+ println!("β {green}All shells already configured{green:#}");+ return;+ }++ // Show what was done+ for result in &results {let bold = Style::new().bold();let shell = result.shell;let path = result.path.display();@@ -169,6 +186,19 @@ fn main() {println!(" {dim}{line}{dim:#}");}}++ // Success summary+ println!();+ let green = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green)));+ let plural = if changes_count == 1 { "" } else { "s" };+ println!("β {green}Configured {changes_count} shell{plural}{green:#}");++ // Show hint about restarting shell+ println!();+ use worktrunk::styling::{HINT, HINT_EMOJI};+ println!(+ "{HINT_EMOJI} {HINT}Restart your shell or run: source <config-file>{HINT:#}"+ );}).map_err(GitError::CommandFailed)}