Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Refactor: Standardize CLI output styling with `anstyle`

Maximilian Roosefe9211aa447
diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644
index 000000000..922905f08
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1,165 @@
+# Worktrunk Development Guidelines
+
+> **Note**: This CLAUDE.md is just getting started. More guidelines will be added as patterns emerge.
+
+## CLI Output Formatting Standards
+
+### The anstyle Ecosystem
+
+All styling uses the **anstyle ecosystem** for composable, auto-detecting terminal output:
+
+- **`anstream`**: Auto-detecting I/O streams (println!, eprintln! macros)
+- **`anstyle`**: Core styling with inline pattern `{style}text{style:#}`
+- **Color detection**: Respects NO_COLOR, CLICOLOR_FORCE, TTY detection
+
+### Message Types
+
+Three canonical message patterns with their emojis:
+
+1. **Errors**: ❌ + red text
+2. **Warnings**: 🟑 + yellow text
+3. **Hints**: πŸ’‘ + dimmed text
+
+### Semantic Style Constants
+
+**Constants defined in `src/styling.rs`:**
+
+- **`ERROR`**: Red (errors, conflicts)
+- **`WARNING`**: Yellow (warnings)
+- **`SUCCESS`**: Green (success)
+- **`HINT`**: Dimmed (hints, secondary information)
+- **`CURRENT`**: Magenta + bold (current worktree)
+- **`ADDITION`**: Green (diffs, additions)
+- **`DELETION`**: Red (diffs, deletions)
+
+### Inline Formatting Pattern
+
+Use anstyle's inline pattern `{style}text{style:#}` where `#` means reset:
+
+```rust
+use worktrunk::styling::{eprintln, ERROR, WARNING, HINT};
+
+// Simple error
+eprintln!("❌ {ERROR}Working tree has uncommitted changes{ERROR:#}");
+
+// Warning
+eprintln!("🟑 {WARNING}Uncommitted changes detected{WARNING:#}");
+
+// Hint
+println!("πŸ’‘ {HINT}Use 'wt list' to see all worktrees{HINT:#}");
+```
+
+### Composing Styles
+
+Compose styles using anstyle methods (`.bold()`, `.fg_color()`, etc.):
+
+```rust
+use worktrunk::styling::{eprintln, AnstyleStyle, ERROR, WARNING};
+
+// Error with bold branch name
+let error_bold = ERROR.bold();
+eprintln!("❌ Branch '{error_bold}{branch}{error_bold:#}' already exists");
+
+// Warning with bold
+let warning_bold = WARNING.bold();
+eprintln!("🟑 {warning_bold}{message}{warning_bold:#}");
+
+// Just bold (no color)
+let bold = AnstyleStyle::new().bold();
+println!("Switched to worktree: {bold}{branch}{bold:#}");
+```
+
+### Branch Name Formatting
+
+**Always format branch names in bold** when they appear in messages:
+
+```rust
+use worktrunk::styling::{AnstyleStyle, ERROR};
+
+// Good - bold branch name in error
+let error_bold = ERROR.bold();
+eprintln!("❌ Branch '{error_bold}{branch}{error_bold:#}' already exists");
+
+// Good - bold in regular message
+let bold = AnstyleStyle::new().bold();
+println!("Switched to worktree: {bold}{branch}{bold:#}");
+
+// Bad - plain branch name
+println!("Switched to worktree: {branch}")
+```
+
+### Color Detection
+
+Colors automatically adjust based on environment:
+- Respects `NO_COLOR` (disables)
+- Respects `CLICOLOR_FORCE` / `FORCE_COLOR` (enables)
+- Auto-detects TTY (colors only on terminals)
+
+All handled automatically by `anstream` macros.
+
+### Design Principles
+
+- **Inline over wrappers** - Use `{style}text{style:#}` pattern, not wrapper functions
+- **Composition over special cases** - Use `.bold()`, `.fg_color()`, not `format_X_with_Y()`
+- **Semantic constants** - Use `ERROR`, `WARNING`, not raw colors
+- **YAGNI for presentation** - Most output needs no styling
+- **Minimal output** - Only use formatting where it adds clarity
+- **Unicode-aware** - Width calculations respect emoji and CJK characters (via `StyledLine`)
+- **Graceful degradation** - Must work without color support
+
+### Complete Examples
+
+```rust
+use worktrunk::styling::{println, eprintln, AnstyleStyle, ERROR, WARNING, HINT, SUCCESS};
+use anstyle::Style;
+
+// Simple error
+eprintln!("❌ {ERROR}Working tree has uncommitted changes{ERROR:#}");
+
+// Error with bold branch name
+let error_bold = ERROR.bold();
+eprintln!("❌ Branch '{error_bold}{branch}{error_bold:#}' already exists");
+
+// Warning with bold
+let warning_bold = WARNING.bold();
+eprintln!("🟑 {warning_bold}Uncommitted changes detected{warning_bold:#}");
+
+// Hint
+println!("πŸ’‘ {HINT}Use 'wt list' to see all worktrees{HINT:#}");
+
+// Success message
+println!("βœ… {SUCCESS}Worktree created successfully{SUCCESS:#}");
+
+// Bold branch name in regular message
+let bold = Style::new().bold();
+println!("Switched to worktree: {bold}{branch}{bold:#}");
+
+// Complex multi-part error
+let error_bold = ERROR.bold();
+eprintln!("❌ Not a fast-forward from '{error_bold}{target_branch}{error_bold:#}' to HEAD");
+
+// Dimmed secondary info
+let dim = Style::new().dimmed();
+println!(" {dim}Path: {path}{dim:#}");
+```
+
+### StyledLine API
+
+For complex table formatting with proper width calculations, use `StyledLine`:
+
+```rust
+use worktrunk::styling::StyledLine;
+use anstyle::{AnsiColor, Color, Style};
+
+let mut line = StyledLine::new();
+let dim = Style::new().dimmed();
+let cyan = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan)));
+
+line.push_styled("Branch", dim);
+line.push_raw(" ");
+line.push_styled("main", cyan);
+
+println!("{}", line.render());
+```
+
+See `src/commands/list/render.rs` for advanced usage.
diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rs
index 1ccb85f3d..d0f42548f 100644
--- a/src/commands/list/mod.rs
+++ b/src/commands/list/mod.rs
@@ -6,6 +6,7 @@ mod spacing_test;
use rayon::prelude::*;
use worktrunk::git::{GitError, Repository};
+use worktrunk::styling::{WARNING, eprintln};
use layout::calculate_responsive_layout;
use render::{format_header_line, format_list_item_line};
@@ -321,7 +322,12 @@ pub fn handle_list(format: crate::OutputFormat, show_branches: bool) -> Result<(
for branch in available_branches {
match BranchInfo::from_branch(&branch, &repo, primary_branch) {
Ok(branch_info) => items.push(ListItem::Branch(branch_info)),
- Err(e) => eprintln!("Warning: Failed to enrich branch '{}': {}", branch, e),
+ Err(e) => {
+ let warning_bold = WARNING.bold();
+ eprintln!(
+ "🟑 Failed to enrich branch {warning_bold}{branch}{warning_bold:#}: {e}"
+ );
+ }
}
}
}
diff --git a/src/commands/list/render.rs b/src/commands/list/render.rs
index a7a147837..64c44d0c7 100644
--- a/src/commands/list/render.rs
+++ b/src/commands/list/render.rs
@@ -1,8 +1,6 @@
use crate::display::{format_relative_time, shorten_path, truncate_at_word_boundary};
-use worktrunk::styling::{
- StyledLine, addition_style, current_style, deletion_style, dim_style, neutral_style,
- primary_style,
-};
+use anstyle::{AnsiColor, Color, Style};
+use worktrunk::styling::{ADDITION, CURRENT, DELETION, StyledLine};
use super::layout::LayoutConfig;
use super::{ListItem, WorktreeInfo};
@@ -43,68 +41,67 @@ pub fn format_all_states(info: &WorktreeInfo) -> String {
pub fn format_header_line(layout: &LayoutConfig) {
let widths = &layout.widths;
let mut line = StyledLine::new();
- let dim = dim_style();
// Branch
let header = format!("{:width$}", "Branch", width = widths.branch);
- line.push_styled(header, dim);
+ line.push_styled(header, Style::new().dimmed());
line.push_raw(" ");
// Age (Time)
if widths.time > 0 {
let header = format!("{:width$}", "Age", width = widths.time);
- line.push_styled(header, dim);
+ line.push_styled(header, Style::new().dimmed());
line.push_raw(" ");
}
// Ahead/behind (commits)
if widths.ahead_behind > 0 {
let header = format!("{:width$}", "Cmts", width = widths.ahead_behind);
- line.push_styled(header, dim);
+ line.push_styled(header, Style::new().dimmed());
line.push_raw(" ");
}
// Branch diff (line diff in commits)
if widths.branch_diff.total > 0 {
let header = format!("{:width$}", "Cmt +/-", width = widths.branch_diff.total);
- line.push_styled(header, dim);
+ line.push_styled(header, Style::new().dimmed());
line.push_raw(" ");
}
// Working tree diff
if widths.working_diff.total > 0 {
let header = format!("{:width$}", "WT +/-", width = widths.working_diff.total);
- line.push_styled(header, dim);
+ line.push_styled(header, Style::new().dimmed());
line.push_raw(" ");
}
// Upstream
if widths.upstream > 0 {
let header = format!("{:width$}", "Remote", width = widths.upstream);
- line.push_styled(header, dim);
+ line.push_styled(header, Style::new().dimmed());
line.push_raw(" ");
}
// Commit (fixed width: 8 chars)
- line.push_styled("Commit ", dim);
+ line.push_styled("Commit ", Style::new().dimmed());
line.push_raw(" ");
// Message
if widths.message > 0 {
let header = format!("{:width$}", "Message", width = widths.message);
- line.push_styled(header, dim);
+ line.push_styled(header, Style::new().dimmed());
line.push_raw(" ");
}
// States
if widths.states > 0 {
let header = format!("{:width$}", "State", width = widths.states);
- line.push_styled(header, dim);
+ line.push_styled(header, Style::new().dimmed());
line.push_raw(" ");
}
// Path
- line.push_styled("Path", dim);
+ line.push_styled("Path", Style::new().dimmed());
println!("{}", line.render());
}
@@ -124,12 +121,6 @@ fn format_item_line(
current_worktree_path: Option<&std::path::PathBuf>,
) {
let widths = &layout.widths;
- let primary = primary_style();
- let current = current_style();
- let green = addition_style();
- let red = deletion_style();
- let yellow = neutral_style();
- let dim = dim_style();
let short_head = &item.commit_head()[..8.min(item.commit_head().len())];
@@ -139,8 +130,8 @@ fn format_item_line(
.map(|p| p == &info.worktree.path)
.unwrap_or(false);
match (is_current, item.is_primary()) {
- (true, _) => Some(current),
- (_, true) => Some(primary),
+ (true, _) => Some(CURRENT),
+ (_, true) => Some(Style::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan)))),
_ => None,
}
});
@@ -164,7 +155,7 @@ fn format_item_line(
format_relative_time(item.timestamp()),
width = widths.time
);
- line.push_styled(time_str, dim);
+ line.push_styled(time_str, Style::new().dimmed());
line.push_raw(" ");
}
@@ -176,7 +167,10 @@ fn format_item_line(
format!("↑{} ↓{}", item.ahead(), item.behind()),
width = widths.ahead_behind
);
- line.push_styled(ahead_behind_text, yellow);
+ line.push_styled(
+ ahead_behind_text,
+ Style::new().fg_color(Some(Color::Ansi(AnsiColor::Yellow))),
+ );
} else {
line.push_raw(" ".repeat(widths.ahead_behind));
}
@@ -199,8 +193,8 @@ fn format_item_line(
let mut diff_segment = StyledLine::new();
// Split at the space between + and -
let split_pos = 1 + widths.branch_diff.added_digits;
- diff_segment.push_styled(&formatted[..split_pos], green);
- diff_segment.push_styled(&formatted[split_pos..], red);
+ diff_segment.push_styled(&formatted[..split_pos], ADDITION);
+ diff_segment.push_styled(&formatted[split_pos..], DELETION);
for segment in diff_segment.segments {
line.push(segment);
}
@@ -228,8 +222,8 @@ fn format_item_line(
let mut diff_segment = StyledLine::new();
// Split at the space between + and -
let split_pos = 1 + widths.working_diff.added_digits;
- diff_segment.push_styled(&formatted[..split_pos], green);
- diff_segment.push_styled(&formatted[split_pos..], red);
+ diff_segment.push_styled(&formatted[..split_pos], ADDITION);
+ diff_segment.push_styled(&formatted[split_pos..], DELETION);
for segment in diff_segment.segments {
line.push(segment);
}
@@ -246,11 +240,11 @@ fn format_item_line(
if widths.upstream > 0 {
if let Some((remote_name, upstream_ahead, upstream_behind)) = item.upstream_info() {
let mut upstream_segment = StyledLine::new();
- upstream_segment.push_styled(remote_name, dim);
+ upstream_segment.push_styled(remote_name, Style::new().dimmed());
upstream_segment.push_raw(" ");
- upstream_segment.push_styled(format!("↑{}", upstream_ahead), green);
+ upstream_segment.push_styled(format!("↑{}", upstream_ahead), ADDITION);
upstream_segment.push_raw(" ");
- upstream_segment.push_styled(format!("↓{}", upstream_behind), red);
+ upstream_segment.push_styled(format!("↓{}", upstream_behind), DELETION);
upstream_segment.pad_to(widths.upstream);
for segment in upstream_segment.segments {
line.push(segment);
@@ -265,7 +259,7 @@ fn format_item_line(
if let Some(style) = text_style {
line.push_styled(short_head, style);
} else {
- line.push_styled(short_head, dim);
+ line.push_styled(short_head, Style::new().dimmed());
}
line.push_raw(" ");
@@ -276,7 +270,7 @@ fn format_item_line(
truncate_at_word_boundary(item.commit_message(), layout.max_message_len),
width = widths.message
);
- line.push_styled(msg, dim);
+ line.push_styled(msg, Style::new().dimmed());
line.push_raw(" ");
}
diff --git a/src/commands/list/spacing_test.rs b/src/commands/list/spacing_test.rs
index 644bb0414..589bf3c94 100644
--- a/src/commands/list/spacing_test.rs
+++ b/src/commands/list/spacing_test.rs
@@ -3,22 +3,21 @@
//! This test verifies that header and data rows align properly,
//! regardless of whether cells have ANSI styling applied.
-use worktrunk::styling::{StyledLine, dim_style, primary_style};
+use anstyle::{AnsiColor, Color, Style};
+use worktrunk::styling::StyledLine;
#[test]
fn test_header_data_alignment_with_and_without_styling() {
// Simulate what happens in the actual rendering
- let dim = dim_style();
- let primary = primary_style();
// Header (always styled with dim)
let mut header = StyledLine::new();
let branch_width = 6;
let branch_header = format!("{:width$}", "Branch", width = branch_width);
- header.push_styled(branch_header, dim);
+ header.push_styled(branch_header, Style::new().dimmed());
header.push_raw(" "); // separator
let age_header = format!("{:width$}", "Age", width = 14);
- header.push_styled(age_header, dim);
+ header.push_styled(age_header, Style::new().dimmed());
println!(
"Header visual: |{}|",
@@ -28,10 +27,13 @@ fn test_header_data_alignment_with_and_without_styling() {
// Data row 1: with styling (styled cell)
let mut row1 = StyledLine::new();
let branch1_text = format!("{:width$}", "main", width = branch_width);
- row1.push_styled(branch1_text.clone(), primary); // Styled
+ row1.push_styled(
+ branch1_text.clone(),
+ Style::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan))),
+ ); // Styled
row1.push_raw(" "); // separator
let time1_text = format!("{:width$}", "23 minutes ago", width = 14);
- row1.push_styled(time1_text, dim);
+ row1.push_styled(time1_text, Style::new().dimmed());
println!(
"Row 1 styled visual: |{}|",
@@ -49,7 +51,7 @@ fn test_header_data_alignment_with_and_without_styling() {
row2.push_raw(branch2_text.clone()); // NOT styled
row2.push_raw(" "); // separator
let time2_text = format!("{:width$}", "23 minutes ago", width = 14);
- row2.push_styled(time2_text, dim);
+ row2.push_styled(time2_text, Style::new().dimmed());
println!(
"Row 2 unstyled visual: |{}|",
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index 7e70d8418..538140ab9 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -1,6 +1,6 @@
use worktrunk::config::WorktrunkConfig;
use worktrunk::git::{GitError, Repository};
-use worktrunk::styling::format_error;
+use worktrunk::styling::{AnstyleStyle, ERROR, println};
use super::worktree::handle_push;
use super::worktree::handle_remove;
@@ -14,16 +14,19 @@ pub fn handle_merge(
let repo = Repository::current();
// Get current branch
- let current_branch = repo
- .current_branch()?
- .ok_or_else(|| GitError::CommandFailed(format_error("Not on a branch (detached HEAD)")))?;
+ let current_branch = repo.current_branch()?.ok_or_else(|| {
+ GitError::CommandFailed(format!(
+ "❌ {ERROR}Not on a branch (detached HEAD){ERROR:#}"
+ ))
+ })?;
// Get target branch (default to default branch if not provided)
let target_branch = target.map_or_else(|| repo.default_branch(), |b| Ok(b.to_string()))?;
// Check if already on target branch
if current_branch == target_branch {
- println!("Already on '{}', nothing to merge", target_branch);
+ let bold = AnstyleStyle::new().bold();
+ println!("Already on {bold}{target_branch}{bold:#}, nothing to merge");
return Ok(());
}
@@ -36,14 +39,15 @@ pub fn handle_merge(
}
// Rebase onto target
- println!("Rebasing onto '{}'...", target_branch);
+ let bold = AnstyleStyle::new().bold();
+ println!("Rebasing onto {bold}{target_branch}{bold:#}...");
repo.run_command(&["rebase", &target_branch]).map_err(|e| {
GitError::CommandFailed(format!("Failed to rebase onto '{}': {}", target_branch, e))
})?;
// Fast-forward push to target branch (reuse handle_push logic)
- println!("Fast-forwarding '{}' to current HEAD...", target_branch);
+ println!("Fast-forwarding {bold}{target_branch}{bold:#} to current HEAD...");
handle_push(Some(&target_branch), false)?;
// Finish worktree unless --keep was specified
@@ -68,7 +72,8 @@ pub fn handle_merge(
let primary_repo = Repository::at(&primary_worktree_dir);
let new_branch = primary_repo.current_branch()?;
if new_branch.as_deref() != Some(&target_branch) {
- println!("Switching to '{}'...", target_branch);
+ let bold = AnstyleStyle::new().bold();
+ println!("Switching to {bold}{target_branch}{bold:#}...");
primary_repo
.run_command(&["switch", &target_branch])
.map_err(|e| {
@@ -79,10 +84,8 @@ pub fn handle_merge(
})?;
}
} else {
- println!(
- "Successfully merged to '{}' (worktree preserved)",
- target_branch
- );
+ let bold = AnstyleStyle::new().bold();
+ println!("Successfully merged to {bold}{target_branch}{bold:#} (worktree preserved)");
}
Ok(())
@@ -109,17 +112,15 @@ fn handle_squash(target_branch: &str) -> Result<(), GitError> {
if commit_count == 0 && has_staged {
// Just staged changes, no commits - would need to commit but this shouldn't happen in merge flow
- return Err(GitError::CommandFailed(format_error(
- "Staged changes without commits - please commit them first",
+ return Err(GitError::CommandFailed(format!(
+ "❌ {ERROR}Staged changes without commits - please commit them first{ERROR:#}"
)));
}
if commit_count == 1 && !has_staged {
// Single commit, no staged changes - nothing to do
- println!(
- "Only 1 commit since '{}' - no squashing needed",
- target_branch
- );
+ let bold = AnstyleStyle::new().bold();
+ println!("Only 1 commit since {bold}{target_branch}{bold:#} - no squashing needed");
return Ok(());
}
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index fd08736dd..ad5f82186 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -71,7 +71,7 @@ use std::path::PathBuf;
use worktrunk::config::{ProjectConfig, WorktrunkConfig};
use worktrunk::git::{GitError, Repository};
use worktrunk::shell::Shell;
-use worktrunk::styling::{format_error, format_error_with_bold, format_hint};
+use worktrunk::styling::{AnstyleStyle, ERROR, HINT, WARNING, eprintln, println};
/// Generate hint message for shell integration setup
///
@@ -106,16 +106,15 @@ impl SwitchResult {
path,
created_branch,
} => {
+ let bold = AnstyleStyle::new().bold();
let msg = if *created_branch {
format!(
- "Created new branch and worktree for '{}' at {}",
- branch,
+ "Created new branch and worktree for {bold}{branch}{bold:#} at {}",
path.display()
)
} else {
format!(
- "Added worktree for existing branch '{}' at {}",
- branch,
+ "Added worktree for existing branch {bold}{branch}{bold:#} at {}",
path.display()
)
};
@@ -135,10 +134,11 @@ impl SwitchResult {
path,
created_branch,
} => {
+ let bold = AnstyleStyle::new().bold();
let msg = if *created_branch {
- format!("Created new branch and worktree for '{}'", branch)
+ format!("Created new branch and worktree for {bold}{branch}{bold:#}")
} else {
- format!("Added worktree for existing branch '{}'", branch)
+ format!("Added worktree for existing branch {bold}{branch}{bold:#}")
};
Some(format!(
"__WORKTRUNK_CD__{}\n{} at {}",
@@ -166,7 +166,8 @@ impl RemoveResult {
pub fn format_user_output(&self) -> Option<String> {
match self {
RemoveResult::AlreadyOnDefault(branch) => {
- Some(format!("Already on default branch '{}'", branch))
+ let bold = AnstyleStyle::new().bold();
+ Some(format!("Already on default branch {bold}{branch}{bold:#}"))
}
RemoveResult::RemovedWorktree { primary_path } => Some(format!(
"Moved to primary worktree and removed worktree\nPath: {}{}",
@@ -174,7 +175,8 @@ impl RemoveResult {
shell_integration_hint()
)),
RemoveResult::SwitchedToDefault(branch) => {
- Some(format!("Switched to default branch '{}'", branch))
+ let bold = AnstyleStyle::new().bold();
+ Some(format!("Switched to default branch {bold}{branch}{bold:#}"))
}
}
}
@@ -202,19 +204,15 @@ pub fn handle_switch(
// Check for conflicting conditions
if create && repo.branch_exists(branch)? {
- return Err(GitError::CommandFailed(format_error_with_bold(
- "Branch '",
- branch,
- "' already exists. Remove --create flag to switch to it.",
+ let error_bold = ERROR.bold();
+ return Err(GitError::CommandFailed(format!(
+ "❌ Branch '{error_bold}{branch}{error_bold:#}' already exists. Remove --create flag to switch to it."
)));
}
// Check if base flag was provided without create flag
if base.is_some() && !create {
- eprintln!(
- "{}",
- worktrunk::styling::format_warning("--base flag is only used with --create, ignoring")
- );
+ eprintln!("🟑 {WARNING}--base flag is only used with --create, ignoring{WARNING:#}");
}
// Check if worktree already exists for this branch
@@ -228,10 +226,9 @@ pub fn handle_switch(
return Ok(SwitchResult::ExistingWorktree(canonical_existing_path));
}
Some(_) => {
- return Err(GitError::CommandFailed(format_error_with_bold(
- "Worktree directory missing for '",
- branch,
- "'. Run 'git worktree prune' to clean up.",
+ let error_bold = ERROR.bold();
+ return Err(GitError::CommandFailed(format!(
+ "❌ Worktree directory missing for '{error_bold}{branch}{error_bold:#}'. Run 'git worktree prune' to clean up."
)));
}
None => {}
@@ -341,7 +338,7 @@ pub fn handle_remove() -> Result<RemoveResult, GitError> {
// Remove the worktree
if let Err(e) = repo.remove_worktree(&worktree_root) {
- eprintln!("Warning: Failed to remove worktree: {}", e);
+ eprintln!("🟑 {WARNING}Failed to remove worktree: {e}{WARNING:#}");
eprintln!(
"You may need to run 'git worktree remove {}' manually",
worktree_root.display()
@@ -405,10 +402,7 @@ fn check_worktree_conflicts(
.collect();
if !overlapping.is_empty() {
- eprintln!(
- "{}",
- format_error("Cannot push: conflicting uncommitted changes in:")
- );
+ eprintln!("❌ {ERROR}Cannot push: conflicting uncommitted changes in:{ERROR:#}");
for file in &overlapping {
eprintln!(" - {}", file);
}
@@ -531,10 +525,12 @@ pub fn handle_push(target: Option<&str>, allow_merge_commits: bool) -> Result<()
// Check if it's a fast-forward
if !repo.is_ancestor(&target_branch, "HEAD")? {
- let error_msg =
- format_error_with_bold("Not a fast-forward from '", &target_branch, "' to HEAD");
- let hint_msg = format_hint(
- "The target branch has commits not in your current branch. Consider 'git pull' or 'git rebase'",
+ let error_bold = ERROR.bold();
+ let error_msg = format!(
+ "❌ Not a fast-forward from '{error_bold}{target_branch}{error_bold:#}' to HEAD"
+ );
+ let hint_msg = format!(
+ "πŸ’‘ {HINT}The target branch has commits not in your current branch. Consider 'git pull' or 'git rebase'{HINT:#}"
);
return Err(GitError::CommandFailed(format!(
"{}\n{}",
@@ -544,8 +540,8 @@ pub fn handle_push(target: Option<&str>, allow_merge_commits: bool) -> Result<()
// Check for merge commits unless allowed
if !allow_merge_commits && repo.has_merge_commits(&target_branch, "HEAD")? {
- return Err(GitError::CommandFailed(format_error(
- "Found merge commits in push range. Use --allow-merge-commits to push non-linear history.",
+ return Err(GitError::CommandFailed(format!(
+ "❌ {ERROR}Found merge commits in push range. Use --allow-merge-commits to push non-linear history.{ERROR:#}"
)));
}
@@ -567,10 +563,8 @@ pub fn handle_push(target: Option<&str>, allow_merge_commits: bool) -> Result<()
} else {
"commits"
};
- println!(
- "Pushing {} {} to '{}'",
- commit_count, commit_text, target_branch
- );
+ let bold = AnstyleStyle::new().bold();
+ println!("Pushing {commit_count} {commit_text} to {bold}{target_branch}{bold:#}");
}
// Get git common dir for the push
@@ -581,6 +575,7 @@ pub fn handle_push(target: Option<&str>, allow_merge_commits: bool) -> Result<()
repo.run_command(&["push", git_common_dir.to_str().unwrap(), &push_target])
.map_err(|e| GitError::CommandFailed(format!("Push failed: {}", e)))?;
- println!("Successfully pushed to '{}'", target_branch);
+ let bold = AnstyleStyle::new().bold();
+ println!("Successfully pushed to {bold}{target_branch}{bold:#}");
Ok(())
}
diff --git a/src/git.rs b/src/git.rs
index 61064f696..f6aa3e81a 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -25,8 +25,8 @@ impl std::fmt::Display for GitError {
GitError::CommandFailed(msg) => write!(f, "{}", msg),
// ParseError messages need formatting
GitError::ParseError(msg) => {
- use crate::styling::format_error;
- write!(f, "{}", format_error(msg))
+ use crate::styling::ERROR;
+ write!(f, "❌ {ERROR}{msg}{ERROR:#}")
}
}
}
@@ -183,8 +183,9 @@ impl Repository {
/// Returns an error if there are uncommitted changes.
pub fn ensure_clean_working_tree(&self) -> Result<(), GitError> {
if self.is_dirty()? {
- return Err(GitError::CommandFailed(crate::styling::format_error(
- "Working tree has uncommitted changes. Commit or stash them first.",
+ use crate::styling::ERROR;
+ return Err(GitError::CommandFailed(format!(
+ "❌ {ERROR}Working tree has uncommitted changes. Commit or stash them first.{ERROR:#}"
)));
}
Ok(())
diff --git a/src/main.rs b/src/main.rs
index fb072215d..e6931405a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,8 +1,9 @@
+use anstyle::Style;
use clap::{CommandFactory, Parser, Subcommand};
use std::process;
use worktrunk::config::WorktrunkConfig;
use worktrunk::git::GitError;
-use worktrunk::styling::{dim_style, should_use_color};
+use worktrunk::styling::println;
mod commands;
mod display;
@@ -165,15 +166,9 @@ fn main() {
result.path.display()
);
// Indent each line of the config content with dim/gray color
- if should_use_color() {
- let style = dim_style();
- for line in result.config_line.lines() {
- println!(" {}{}{}", style.render(), line, style.render_reset());
- }
- } else {
- for line in result.config_line.lines() {
- println!(" {}", line);
- }
+ for line in result.config_line.lines() {
+ let dim = Style::new().dimmed();
+ println!(" {dim}{line}{dim:#}");
}
}
})
diff --git a/src/styling.rs b/src/styling.rs
index cecb94d46..28daf0c92 100644
--- a/src/styling.rs
+++ b/src/styling.rs
@@ -1,171 +1,62 @@
//! Consolidated styling module for terminal output.
//!
-//! This module provides:
-//! - Color/style detection based on environment variables
-//! - Formatted message functions (error, warning, hint, etc.)
-//! - Styled string/line types for building complex output
+//! This module uses the anstyle ecosystem:
+//! - anstream for auto-detecting color support
+//! - anstyle for composable styling
+//! - Semantic style constants for domain-specific use
use anstyle::{AnsiColor, Color, Style};
-use std::io::IsTerminal;
use unicode_width::UnicodeWidthStr;
// ============================================================================
-// Style Definitions (as constant functions to avoid repeated allocation)
+// Re-exports from anstream (auto-detecting output)
// ============================================================================
-/// Get error style (red)
-pub fn error_style() -> Style {
- Style::new().fg_color(Some(Color::Ansi(AnsiColor::Red)))
-}
-
-/// Get warning style (yellow)
-pub fn warning_style() -> Style {
- Style::new().fg_color(Some(Color::Ansi(AnsiColor::Yellow)))
-}
-
-/// Get hint style (dimmed)
-pub fn hint_style() -> Style {
- Style::new().dimmed()
-}
-
-/// Get success style (green)
-pub fn success_style() -> Style {
- Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green)))
-}
-
-/// Get bold style
-pub fn bold_style() -> Style {
- Style::new().bold()
-}
+/// Auto-detecting println that respects NO_COLOR, CLICOLOR_FORCE, and terminal capabilities
+pub use anstream::println;
-/// Get dim style
-pub fn dim_style() -> Style {
- Style::new().dimmed()
-}
+/// Auto-detecting eprintln that respects NO_COLOR, CLICOLOR_FORCE, and terminal capabilities
+pub use anstream::eprintln;
-/// Get error bold style (red + bold)
-pub fn error_bold_style() -> Style {
- Style::new()
- .fg_color(Some(Color::Ansi(AnsiColor::Red)))
- .bold()
-}
+/// Auto-detecting print that respects NO_COLOR, CLICOLOR_FORCE, and terminal capabilities
+pub use anstream::print;
-/// Get primary style for worktrees (cyan)
-pub fn primary_style() -> Style {
- Style::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan)))
-}
-
-/// Get current style for worktrees (magenta + bold)
-pub fn current_style() -> Style {
- Style::new()
- .bold()
- .fg_color(Some(Color::Ansi(AnsiColor::Magenta)))
-}
-
-/// Get addition style for diffs (green)
-pub fn addition_style() -> Style {
- Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green)))
-}
-
-/// Get deletion style for diffs (red)
-pub fn deletion_style() -> Style {
- Style::new().fg_color(Some(Color::Ansi(AnsiColor::Red)))
-}
-
-/// Get neutral style for diffs (yellow)
-pub fn neutral_style() -> Style {
- Style::new().fg_color(Some(Color::Ansi(AnsiColor::Yellow)))
-}
+/// Auto-detecting eprint that respects NO_COLOR, CLICOLOR_FORCE, and terminal capabilities
+pub use anstream::eprint;
// ============================================================================
-// Color Detection
+// Re-exports from anstyle (for composition)
// ============================================================================
-/// Determines if colored output should be used based on environment
-fn should_use_color_with_env(no_color: bool, force_color: bool, is_terminal: bool) -> bool {
- if force_color {
- return true;
- }
- if no_color {
- return false;
- }
- is_terminal
-}
-
-/// Determines if colored output should be used
-pub fn should_use_color() -> bool {
- should_use_color_with_env(
- std::env::var("NO_COLOR").is_ok(),
- std::env::var("CLICOLOR_FORCE").is_ok() || std::env::var("FORCE_COLOR").is_ok(),
- std::io::stderr().is_terminal(),
- )
-}
+/// Re-export Style for users who want to compose custom styles
+pub use anstyle::Style as AnstyleStyle;
// ============================================================================
-// Formatted Message Functions
+// Semantic Style Constants
// ============================================================================
-/// Format an error message with red color and ❌ emoji
-pub fn format_error(msg: &str) -> String {
- if should_use_color() {
- let style = error_style();
- format!("{}❌ {}{}", style.render(), msg, style.render_reset())
- } else {
- format!("❌ {}", msg)
- }
-}
+/// Error style (red) - use as `{ERROR}text{ERROR:#}`
+pub const ERROR: Style = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Red)));
-/// Format a warning message with yellow color and 🟑 emoji
-pub fn format_warning(msg: &str) -> String {
- if should_use_color() {
- let style = warning_style();
- format!("{}🟑 {}{}", style.render(), msg, style.render_reset())
- } else {
- format!("🟑 {}", msg)
- }
-}
+/// Warning style (yellow) - use as `{WARNING}text{WARNING:#}`
+pub const WARNING: Style = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Yellow)));
-/// Format a hint message with dim color and πŸ’‘ emoji
-pub fn format_hint(msg: &str) -> String {
- if should_use_color() {
- let style = hint_style();
- format!("{}πŸ’‘ {}{}", style.render(), msg, style.render_reset())
- } else {
- format!("πŸ’‘ {}", msg)
- }
-}
+/// Hint style (dimmed) - use as `{HINT}text{HINT:#}`
+pub const HINT: Style = Style::new().dimmed();
-/// Format text with bold styling
-pub fn bold(text: &str) -> String {
- if should_use_color() {
- let style = bold_style();
- format!("{}{}{}", style.render(), text, style.render_reset())
- } else {
- text.to_string()
- }
-}
+/// Success style (green) - use as `{SUCCESS}text{SUCCESS:#}`
+pub const SUCCESS: Style = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green)));
-/// Format an error message with bold emphasis on specific parts
-///
-/// Example: `format_error_with_bold("Branch '", "feature-x", "' already exists")`
-pub fn format_error_with_bold(prefix: &str, emphasized: &str, suffix: &str) -> String {
- if should_use_color() {
- let error = error_style();
- let error_bold = error_bold_style();
- format!(
- "{}❌ {}{}{}{}{}{}",
- error.render(),
- prefix,
- error_bold.render(),
- emphasized,
- error.render(), // Back to regular red
- suffix,
- error.render_reset()
- )
- } else {
- format!("❌ {}{}{}", prefix, emphasized, suffix)
- }
-}
+/// Current worktree style (magenta + bold)
+pub const CURRENT: Style = Style::new()
+ .bold()
+ .fg_color(Some(Color::Ansi(AnsiColor::Magenta)));
+
+/// Addition style for diffs (green)
+pub const ADDITION: Style = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green)));
+
+/// Deletion style for diffs (red)
+pub const DELETION: Style = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Red)));
// ============================================================================
// Styled Output Types
@@ -262,25 +153,6 @@ impl StyledLine {
mod tests {
use super::*;
- // Color detection tests
- #[test]
- fn test_should_use_color_force_color() {
- assert!(should_use_color_with_env(false, true, false));
- assert!(should_use_color_with_env(true, true, false));
- }
-
- #[test]
- fn test_should_use_color_no_color() {
- assert!(!should_use_color_with_env(true, false, true));
- assert!(!should_use_color_with_env(true, false, false));
- }
-
- #[test]
- fn test_should_use_color_terminal() {
- assert!(should_use_color_with_env(false, false, true));
- assert!(!should_use_color_with_env(false, false, false));
- }
-
// StyledString tests
#[test]
fn test_styled_string_width() {
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap b/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap
index 89c3d6a54..f35bec46a 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap
@@ -5,6 +5,7 @@ info:
args:
- merge
env:
+ CLICOLOR_FORCE: "1"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
@@ -17,6 +18,6 @@ info:
success: true
exit_code: 0
----- stdout -----
-Already on 'main', nothing to merge
+Already on main, nothing to merge
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap b/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap
index 114664107..c0cad5f4d 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap
@@ -21,4 +21,4 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Working tree has uncommitted changes. Commit or stash them first.
+❌ Working tree has uncommitted changes. Commit or stash them first.
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_error_detached_head.snap b/tests/snapshots/integration__integration_tests__merge__merge_error_detached_head.snap
index b7983b32c..452848f9a 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_error_detached_head.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_error_detached_head.snap
@@ -21,4 +21,4 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Not on a branch (detached HEAD)
+❌ Not on a branch (detached HEAD)
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_fast_forward.snap b/tests/snapshots/integration__integration_tests__merge__merge_fast_forward.snap
index bd9bd77af..3e83ba151 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_fast_forward.snap
@@ -19,10 +19,10 @@ info:
success: true
exit_code: 0
----- stdout -----
-Rebasing onto 'main'...
-Fast-forwarding 'main' to current HEAD...
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Rebasing onto main...
+Fast-forwarding main to current HEAD...
+Pushing 1 commit to main
+Successfully pushed to main
Cleaning up worktree...
Moved to primary worktree and removed worktree
Path: [REPO]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_not_fast_forward.snap b/tests/snapshots/integration__integration_tests__merge__merge_not_fast_forward.snap
index bd9bd77af..3e83ba151 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_not_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_not_fast_forward.snap
@@ -19,10 +19,10 @@ info:
success: true
exit_code: 0
----- stdout -----
-Rebasing onto 'main'...
-Fast-forwarding 'main' to current HEAD...
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Rebasing onto main...
+Fast-forwarding main to current HEAD...
+Pushing 1 commit to main
+Successfully pushed to main
Cleaning up worktree...
Moved to primary worktree and removed worktree
Path: [REPO]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap
index a816cfe99..53a7b60e3 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap
@@ -22,10 +22,10 @@ exit_code: 0
----- stdout -----
Squashing 3 commits into one...
Successfully squashed 3 commits into one
-Rebasing onto 'main'...
-Fast-forwarding 'main' to current HEAD...
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Rebasing onto main...
+Fast-forwarding main to current HEAD...
+Pushing 1 commit to main
+Successfully pushed to main
Cleaning up worktree...
Moved to primary worktree and removed worktree
Path: [REPO]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap
index a60d0d3cf..189096255 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap
@@ -23,10 +23,10 @@ exit_code: 0
----- stdout -----
Squashing 2 commits into one...
Successfully squashed 2 commits into one
-Rebasing onto 'main'...
-Fast-forwarding 'main' to current HEAD...
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Rebasing onto main...
+Fast-forwarding main to current HEAD...
+Pushing 1 commit to main
+Successfully pushed to main
Cleaning up worktree...
Moved to primary worktree and removed worktree
Path: [REPO]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_single_commit.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_single_commit.snap
index e0ced77fe..582654fca 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_single_commit.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_single_commit.snap
@@ -20,11 +20,11 @@ info:
success: true
exit_code: 0
----- stdout -----
-Only 1 commit since 'main' - no squashing needed
-Rebasing onto 'main'...
-Fast-forwarding 'main' to current HEAD...
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Only 1 commit since main - no squashing needed
+Rebasing onto main...
+Fast-forwarding main to current HEAD...
+Pushing 1 commit to main
+Successfully pushed to main
Cleaning up worktree...
Moved to primary worktree and removed worktree
Path: [REPO]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap
index b705acd31..45b106d3c 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap
@@ -24,10 +24,10 @@ exit_code: 0
----- stdout -----
Squashing 2 commits into one...
Successfully squashed 2 commits into one
-Rebasing onto 'main'...
-Fast-forwarding 'main' to current HEAD...
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Rebasing onto main...
+Fast-forwarding main to current HEAD...
+Pushing 1 commit to main
+Successfully pushed to main
Cleaning up worktree...
Moved to primary worktree and removed worktree
Path: [REPO]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_to_default.snap b/tests/snapshots/integration__integration_tests__merge__merge_to_default.snap
index 47a59568d..84da2e241 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_to_default.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_to_default.snap
@@ -18,10 +18,10 @@ info:
success: true
exit_code: 0
----- stdout -----
-Rebasing onto 'main'...
-Fast-forwarding 'main' to current HEAD...
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Rebasing onto main...
+Fast-forwarding main to current HEAD...
+Pushing 1 commit to main
+Successfully pushed to main
Cleaning up worktree...
Moved to primary worktree and removed worktree
Path: [REPO]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_with_keep.snap b/tests/snapshots/integration__integration_tests__merge__merge_with_keep.snap
index aec57f5d1..4b54fc050 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_with_keep.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_with_keep.snap
@@ -7,6 +7,7 @@ info:
- main
- "--keep"
env:
+ CLICOLOR_FORCE: "1"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
@@ -19,10 +20,10 @@ info:
success: true
exit_code: 0
----- stdout -----
-Rebasing onto 'main'...
-Fast-forwarding 'main' to current HEAD...
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
-Successfully merged to 'main' (worktree preserved)
+Rebasing onto main...
+Fast-forwarding main to current HEAD...
+Pushing 1 commit to main
+Successfully pushed to main
+Successfully merged to main (worktree preserved)
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_empty_array.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_empty_array.snap
index 744357e6a..7d4ea537f 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_empty_array.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_empty_array.snap
@@ -20,7 +20,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Created new branch and worktree for 'feature' at [REPO].feature
+Created new branch and worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_failing_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_failing_command.snap
index 872838e59..e0515fcc0 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_failing_command.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_failing_command.snap
@@ -20,7 +20,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Created new branch and worktree for 'feature' at [REPO].feature
+Created new branch and worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_toml.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_toml.snap
index e0ce83428..8059ee3ae 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_toml.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_toml.snap
@@ -20,7 +20,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Created new branch and worktree for 'feature' at [REPO].feature
+Created new branch and worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_commands.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_commands.snap
index 99264257f..aec39a194 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_commands.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_commands.snap
@@ -22,7 +22,7 @@ exit_code: 0
----- stdout -----
First
Second
-Created new branch and worktree for 'feature' at [REPO].feature
+Created new branch and worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_no_config.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_no_config.snap
index 744357e6a..7d4ea537f 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_no_config.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_no_config.snap
@@ -20,7 +20,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Created new branch and worktree for 'feature' at [REPO].feature
+Created new branch and worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_with_approval.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_with_approval.snap
index c6830f68c..e7d6bcf07 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_with_approval.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_with_approval.snap
@@ -21,7 +21,7 @@ success: true
exit_code: 0
----- stdout -----
Setup complete
-Created new branch and worktree for 'feature' at [REPO].feature
+Created new branch and worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
diff --git a/tests/snapshots/integration__integration_tests__push__push_dirty_target.snap b/tests/snapshots/integration__integration_tests__push__push_dirty_target.snap
index 7f7bc34f0..3012fc04e 100644
--- a/tests/snapshots/integration__integration_tests__push__push_dirty_target.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_dirty_target.snap
@@ -21,6 +21,6 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Cannot push: conflicting uncommitted changes in:
+❌ Cannot push: conflicting uncommitted changes in:
- conflict.txt
Commit or stash changes in [REPO] first
diff --git a/tests/snapshots/integration__integration_tests__push__push_error_not_fast_forward.snap b/tests/snapshots/integration__integration_tests__push__push_error_not_fast_forward.snap
index 8b8092ef7..27a518a85 100644
--- a/tests/snapshots/integration__integration_tests__push__push_error_not_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_error_not_fast_forward.snap
@@ -21,5 +21,5 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Not a fast-forward from 'main' to HEAD
-πŸ’‘ The target branch has commits not in your current branch. Consider 'git pull' or 'git rebase'
+❌ Not a fast-forward from 'main' to HEAD
+πŸ’‘ The target branch has commits not in your current branch. Consider 'git pull' or 'git rebase'
diff --git a/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap b/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap
index 4b4e0214c..edf78ca94 100644
--- a/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap
@@ -21,4 +21,4 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Found merge commits in push range. Use --allow-merge-commits to push non-linear history.
+❌ Found merge commits in push range. Use --allow-merge-commits to push non-linear history.
diff --git a/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap b/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap
index d6c09cacb..18aaa1f03 100644
--- a/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap
@@ -6,6 +6,7 @@ info:
- push
- main
env:
+ CLICOLOR_FORCE: "1"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
@@ -18,7 +19,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Pushing 1 commit to main
+Successfully pushed to main
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap b/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap
index d6c09cacb..18aaa1f03 100644
--- a/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap
@@ -6,6 +6,7 @@ info:
- push
- main
env:
+ CLICOLOR_FORCE: "1"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
@@ -18,7 +19,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Pushing 1 commit to main
+Successfully pushed to main
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__push__push_to_default.snap b/tests/snapshots/integration__integration_tests__push__push_to_default.snap
index 6d3d57754..c3bfd30e7 100644
--- a/tests/snapshots/integration__integration_tests__push__push_to_default.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_to_default.snap
@@ -5,6 +5,7 @@ info:
args:
- push
env:
+ CLICOLOR_FORCE: "1"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
@@ -17,7 +18,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Pushing 1 commit to 'main'
-Successfully pushed to 'main'
+Pushing 1 commit to main
+Successfully pushed to main
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_already_on_default.snap b/tests/snapshots/integration__integration_tests__remove__remove_already_on_default.snap
index 472c5d5aa..b25ffe3f9 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_already_on_default.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_already_on_default.snap
@@ -1,10 +1,11 @@
---
-source: tests/integration_tests/finish.rs
+source: tests/integration_tests/remove.rs
info:
program: wt
args:
- - finish
+ - remove
env:
+ CLICOLOR_FORCE: "1"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
@@ -17,6 +18,6 @@ info:
success: true
exit_code: 0
----- stdout -----
-Already on default branch 'main'
+Already on default branch main
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snap b/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snap
index 25f856d2d..b731f2e36 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snap
@@ -20,4 +20,4 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Working tree has uncommitted changes. Commit or stash them first.
+❌ Working tree has uncommitted changes. Commit or stash them first.
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snap b/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snap
index d50ed18f9..44bc84681 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snap
@@ -1,10 +1,11 @@
---
-source: tests/integration_tests/finish.rs
+source: tests/integration_tests/remove.rs
info:
program: wt
args:
- - finish
+ - remove
env:
+ CLICOLOR_FORCE: "1"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
@@ -17,6 +18,6 @@ info:
success: true
exit_code: 0
----- stdout -----
-Switched to default branch 'main'
+Switched to default branch main
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_base_without_create.snap b/tests/snapshots/integration__integration_tests__switch__switch_base_without_create.snap
index 9355bb26a..e30fe2759 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_base_without_create.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_base_without_create.snap
@@ -23,4 +23,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-🟑 --base flag is only used with --create, ignoring
+🟑 --base flag is only used with --create, ignoring
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snap b/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snap
index 69c514305..38b9d7db6 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snap
@@ -22,4 +22,4 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Branch 'feature-y' already exists. Remove --create flag to switch to it.
+❌ Branch 'feature-y' already exists. Remove --create flag to switch to it.
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_create_new.snap b/tests/snapshots/integration__integration_tests__switch__switch_create_new.snap
index 7e3737a9c..a6db01464 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_create_new.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_create_new.snap
@@ -20,7 +20,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Created new branch and worktree for 'feature-x' at [REPO].feature-x
+Created new branch and worktree for feature-x at [REPO].feature-x
To enable automatic cd, run: wt configure-shell
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_error_missing_directory.snap b/tests/snapshots/integration__integration_tests__switch__switch_error_missing_directory.snap
index 70ecc784e..436572cc1 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_error_missing_directory.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_error_missing_directory.snap
@@ -21,4 +21,4 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Worktree directory missing for 'missing-wt'. Run 'git worktree prune' to clean up.
+❌ Worktree directory missing for 'missing-wt'. Run 'git worktree prune' to clean up.
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_execute_creates_file.snap b/tests/snapshots/integration__integration_tests__switch__switch_execute_creates_file.snap
index 3fc7be4a1..2fb894a08 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_execute_creates_file.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_execute_creates_file.snap
@@ -22,7 +22,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Created new branch and worktree for 'file-test' at [REPO].file-test
+Created new branch and worktree for file-test at [REPO].file-test
To enable automatic cd, run: wt configure-shell
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_execute_success.snap b/tests/snapshots/integration__integration_tests__switch__switch_execute_success.snap
index 69e61d25c..7451bd884 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_execute_success.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_execute_success.snap
@@ -23,7 +23,7 @@ success: true
exit_code: 0
----- stdout -----
test output
-Created new branch and worktree for 'exec-test' at [REPO].exec-test
+Created new branch and worktree for exec-test at [REPO].exec-test
To enable automatic cd, run: wt configure-shell
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_internal_mode.snap b/tests/snapshots/integration__integration_tests__switch__switch_internal_mode.snap
index d878b7a95..cb2e5759a 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_internal_mode.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_internal_mode.snap
@@ -22,6 +22,6 @@ success: true
exit_code: 0
----- stdout -----
__WORKTRUNK_CD__[REPO].internal-test
-Created new branch and worktree for 'internal-test' at [REPO].internal-test
+Created new branch and worktree for internal-test at [REPO].internal-test
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_with_base.snap b/tests/snapshots/integration__integration_tests__switch__switch_with_base.snap
index 415a9ae7f..a2523adc6 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_with_base.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_with_base.snap
@@ -22,7 +22,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-Created new branch and worktree for 'feature-with-base' at [REPO].feature-with-base
+Created new branch and worktree for feature-with-base at [REPO].feature-with-base
To enable automatic cd, run: wt configure-shell