Skip to content

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

Centralize message formatting in styling module for consistent error/status output

Maximilian Roos69d49d281fa2
diff --git a/src/commands/command_approval.rs b/src/commands/command_approval.rs
index f809ef988..3e7801fe0 100644
--- a/src/commands/command_approval.rs
+++ b/src/commands/command_approval.rs
@@ -8,7 +8,8 @@ use color_print::cformat;
use worktrunk::config::{Command, WorktrunkConfig};
use worktrunk::git::GitError;
use worktrunk::styling::{
- INFO_EMOJI, PROMPT_EMOJI, WARNING_EMOJI, eprint, eprintln, format_bash_with_gutter, stderr,
+ INFO_EMOJI, PROMPT_EMOJI, WARNING_EMOJI, eprint, eprintln, format_bash_with_gutter,
+ hint_message, stderr, warning_message,
};
/// Batch approval helper used when multiple commands are queued for execution.
@@ -65,8 +66,10 @@ pub fn approve_command_batch(
}
if updated && let Err(e) = fresh_config.save() {
- let _ = output::warning(format!("Failed to save command approval: {e}"));
- let _ = output::hint("Approval will be requested again next time.");
+ let _ = output::print(warning_message(format!(
+ "Failed to save command approval: {e}"
+ )));
+ let _ = output::print(hint_message("Approval will be requested again next time."));
}
}
diff --git a/src/commands/commit.rs b/src/commands/commit.rs
index 05266489a..bbb0acb12 100644
--- a/src/commands/commit.rs
+++ b/src/commands/commit.rs
@@ -2,7 +2,7 @@ use anyhow::Context;
use color_print::cformat;
use worktrunk::config::CommitGenerationConfig;
use worktrunk::git::Repository;
-use worktrunk::styling::format_with_gutter;
+use worktrunk::styling::{format_with_gutter, hint_message, progress_message, success_message};
use super::command_executor::CommandContext;
use super::hooks::HookPipeline;
@@ -67,9 +67,9 @@ impl<'a> CommitGenerator<'a> {
pub fn emit_hint_if_needed(&self) -> anyhow::Result<()> {
if !self.config.is_configured() {
- crate::output::hint(cformat!(
+ crate::output::print(hint_message(cformat!(
"Using fallback commit message. Run <bright-black>wt config --help</> for LLM setup guide"
- ))?;
+ )))?;
}
Ok(())
}
@@ -111,7 +111,7 @@ impl<'a> CommitGenerator<'a> {
cformat!("{action} <bright-black>({parts_str}</>{paren_close}")
};
- crate::output::progress(full_progress_msg)?;
+ crate::output::print(progress_message(full_progress_msg))?;
self.emit_hint_if_needed()?;
let commit_message = crate::llm::generate_commit_message(self.config)?;
@@ -127,7 +127,9 @@ impl<'a> CommitGenerator<'a> {
.trim()
.to_string();
- crate::output::success(cformat!("Committed changes @ <dim>{commit_hash}</>"))?;
+ crate::output::print(success_message(cformat!(
+ "Committed changes @ <dim>{commit_hash}</>"
+ )))?;
Ok(())
}
@@ -143,9 +145,9 @@ impl CommitOptions<'_> {
.unwrap_or(false);
if self.no_verify && has_pre_commit {
- crate::output::hint(cformat!(
+ crate::output::print(hint_message(cformat!(
"Skipping pre-commit hook (<bright-black>--no-verify</>)"
- ))?;
+ )))?;
} else if let Some(ref config) = project_config {
let pipeline = HookPipeline::new(*self.ctx);
pipeline.run_pre_commit(config, self.target_branch, self.auto_trust)?;
diff --git a/src/commands/config.rs b/src/commands/config.rs
index 782d4d77e..53439b9d3 100644
--- a/src/commands/config.rs
+++ b/src/commands/config.rs
@@ -10,6 +10,7 @@ use worktrunk::path::format_path_for_display;
use worktrunk::shell::Shell;
use worktrunk::styling::{
ERROR_EMOJI, HINT_EMOJI, INFO_EMOJI, WARNING_EMOJI, format_toml, format_with_gutter,
+ hint_message, info_message, progress_message, success_message, warning_message,
};
use super::configure_shell::{ConfigAction, scan_shell_configs};
@@ -80,17 +81,17 @@ fn create_config_file(
) -> anyhow::Result<()> {
// Check if file already exists
if path.exists() {
- output::info(cformat!(
+ output::print(info_message(cformat!(
"{config_type} already exists: <bold>{}</>",
format_path_for_display(&path)
- ))?;
+ )))?;
output::blank()?;
- output::hint(cformat!(
+ output::print(hint_message(cformat!(
"Use <bright-black>wt config show</> to view existing configuration"
- ))?;
- output::hint(cformat!(
+ )))?;
+ output::print(hint_message(cformat!(
"Use <bright-black>wt config create --help</> for config format reference"
- ))?;
+ )))?;
return Ok(());
}
@@ -104,14 +105,14 @@ fn create_config_file(
std::fs::write(&path, commented_config).context("Failed to write config file")?;
// Success message
- output::success(cformat!(
+ output::print(success_message(cformat!(
"Created {}: <bold>{}</>",
config_type.to_lowercase(),
format_path_for_display(&path)
- ))?;
+ )))?;
output::blank()?;
for hint in success_hints {
- output::hint(*hint)?;
+ output::print(hint_message(*hint))?;
}
Ok(())
@@ -152,7 +153,7 @@ pub fn handle_config_show(doctor: bool) -> anyhow::Result<()> {
/// Run diagnostic checks on configuration
fn run_doctor_checks() -> anyhow::Result<()> {
- output::info("Running diagnostic checks...")?;
+ output::print(info_message("Running diagnostic checks..."))?;
output::blank()?;
// Test commit generation
@@ -160,10 +161,10 @@ fn run_doctor_checks() -> anyhow::Result<()> {
let commit_config = &config.commit_generation;
if !commit_config.is_configured() {
- output::warning("Commit generation is not configured")?;
- output::hint(cformat!(
+ output::print(warning_message("Commit generation is not configured"))?;
+ output::print(hint_message(cformat!(
"Add <bright-black>[commit-generation]</> section to enable LLM commit messages"
- ))?;
+ )))?;
return Ok(());
}
@@ -177,22 +178,24 @@ fn run_doctor_checks() -> anyhow::Result<()> {
}
);
- output::progress(cformat!(
+ output::print(progress_message(cformat!(
"Testing commit generation with <bold>{command_display}</>"
- ))?;
+ )))?;
match test_commit_generation(commit_config) {
Ok(message) => {
- output::success("Commit generation working")?;
+ output::print(success_message("Commit generation working"))?;
output::blank()?;
- output::info("Sample generated message:")?;
+ output::print(info_message("Sample generated message:"))?;
output::gutter(format_with_gutter(&message, "", None))?;
}
Err(e) => {
output::print(cformat!("{ERROR_EMOJI} <red>Commit generation failed</>"))?;
output::gutter(format_with_gutter(&e.to_string(), "", None))?;
output::blank()?;
- output::hint("Check that the command is installed and API keys are configured")?;
+ output::print(hint_message(
+ "Check that the command is installed and API keys are configured",
+ ))?;
}
}
@@ -504,7 +507,7 @@ pub fn handle_var_get(key: &str, refresh: bool, branch: Option<String>) -> anyho
match key {
"default-branch" => {
let branch_name = if refresh {
- crate::output::progress("Querying remote for default branch...")?;
+ crate::output::print(progress_message("Querying remote for default branch..."))?;
repo.refresh_default_branch()?
} else {
repo.default_branch()?
@@ -540,7 +543,7 @@ pub fn handle_var_get(key: &str, refresh: bool, branch: Option<String>) -> anyho
}
if refresh {
- crate::output::progress("Fetching CI status...")?;
+ crate::output::print(progress_message("Fetching CI status..."))?;
// Clear cache to force refresh
let config_key = format!(
"worktrunk.ci.{}",
@@ -594,9 +597,9 @@ pub fn handle_var_set(key: &str, value: String, branch: Option<String>) -> anyho
let config_key = format!("worktrunk.marker.{}", branch_name);
repo.run_command(&["config", &config_key, &value])?;
- crate::output::success(cformat!(
+ crate::output::print(success_message(cformat!(
"Set marker for <bold>{branch_name}</> to <bold>{value}</>"
- ))?;
+ )))?;
}
_ => anyhow::bail!("Unknown variable: {key}. Valid variables: marker"),
}
@@ -627,12 +630,12 @@ pub fn handle_var_clear(key: &str, branch: Option<String>, all: bool) -> anyhow:
}
if cleared_count == 0 {
- crate::output::info("No markers to clear")?;
+ crate::output::print(info_message("No markers to clear"))?;
} else {
- crate::output::success(cformat!(
+ crate::output::print(success_message(cformat!(
"Cleared <bold>{cleared_count}</> marker{}",
if cleared_count == 1 { "" } else { "s" }
- ))?;
+ )))?;
}
} else {
// Clear specific branch marker
@@ -645,7 +648,9 @@ pub fn handle_var_clear(key: &str, branch: Option<String>, all: bool) -> anyhow:
repo.run_command(&["config", "--unset", &config_key])
.context("Failed to clear marker (may not be set)")?;
- crate::output::success(cformat!("Cleared marker for <bold>{branch_name}</>"))?;
+ crate::output::print(success_message(cformat!(
+ "Cleared marker for <bold>{branch_name}</>"
+ )))?;
}
}
_ => anyhow::bail!("Unknown variable: {key}. Valid variables: marker"),
@@ -659,7 +664,7 @@ pub fn handle_cache_show() -> anyhow::Result<()> {
let repo = Repository::current();
// Show default branch cache
- crate::output::info("Default branch cache:")?;
+ crate::output::print(info_message("Default branch cache:"))?;
match repo.default_branch() {
Ok(branch) => crate::output::gutter(format_with_gutter(&branch, "", None))?,
Err(_) => crate::output::gutter(format_with_gutter("(not cached)", "", None))?,
@@ -667,7 +672,7 @@ pub fn handle_cache_show() -> anyhow::Result<()> {
crate::output::blank()?;
// Show CI status cache
- crate::output::info("CI status cache:")?;
+ crate::output::print(info_message("CI status cache:"))?;
let entries = CachedCiStatus::list_all(&repo);
if entries.is_empty() {
@@ -703,12 +708,12 @@ pub fn handle_cache_clear(cache_type: Option<String>) -> anyhow::Result<()> {
Some("ci") => {
let cleared = CachedCiStatus::clear_all(&repo);
if cleared == 0 {
- crate::output::info("No CI cache entries to clear")?;
+ crate::output::print(info_message("No CI cache entries to clear"))?;
} else {
- crate::output::success(cformat!(
+ crate::output::print(success_message(cformat!(
"Cleared <bold>{cleared}</> CI cache entr{}",
if cleared == 1 { "y" } else { "ies" }
- ))?;
+ )))?;
}
}
Some("default-branch") => {
@@ -716,20 +721,20 @@ pub fn handle_cache_clear(cache_type: Option<String>) -> anyhow::Result<()> {
.run_command(&["config", "--unset", "worktrunk.defaultBranch"])
.is_ok()
{
- crate::output::success("Cleared default branch cache")?;
+ crate::output::print(success_message("Cleared default branch cache"))?;
} else {
- crate::output::info("No default branch cache to clear")?;
+ crate::output::print(info_message("No default branch cache to clear"))?;
}
}
Some("logs") => {
let cleared = clear_logs(&repo)?;
if cleared == 0 {
- crate::output::info("No logs to clear")?;
+ crate::output::print(info_message("No logs to clear"))?;
} else {
- crate::output::success(cformat!(
+ crate::output::print(success_message(cformat!(
"Cleared <bold>{cleared}</> log file{}",
if cleared == 1 { "" } else { "s" }
- ))?;
+ )))?;
}
}
None => {
@@ -740,9 +745,9 @@ pub fn handle_cache_clear(cache_type: Option<String>) -> anyhow::Result<()> {
let cleared_logs = clear_logs(&repo)? > 0;
if cleared_default || cleared_ci || cleared_logs {
- crate::output::success("Cleared all caches")?;
+ crate::output::print(success_message("Cleared all caches"))?;
} else {
- crate::output::info("No caches to clear")?;
+ crate::output::print(info_message("No caches to clear"))?;
}
}
Some(unknown) => {
@@ -784,11 +789,13 @@ fn clear_logs(repo: &Repository) -> anyhow::Result<usize> {
pub fn handle_cache_refresh() -> anyhow::Result<()> {
let repo = Repository::current();
- crate::output::progress("Querying remote for default branch...")?;
+ crate::output::print(progress_message("Querying remote for default branch..."))?;
let branch = repo.refresh_default_branch()?;
- crate::output::success(cformat!("Cache refreshed: <bold>{branch}</>"))?;
+ crate::output::print(success_message(cformat!(
+ "Cache refreshed: <bold>{branch}</>"
+ )))?;
Ok(())
}
diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rs
index fa1c0b434..1173dd70e 100644
--- a/src/commands/configure_shell.rs
+++ b/src/commands/configure_shell.rs
@@ -3,7 +3,9 @@ use std::io::{self, BufRead, BufReader, Write};
use std::path::{Path, PathBuf};
use worktrunk::path::format_path_for_display;
use worktrunk::shell::{self, Shell};
-use worktrunk::styling::{INFO_EMOJI, PROGRESS_EMOJI, SUCCESS_EMOJI, format_bash_with_gutter};
+use worktrunk::styling::{
+ INFO_EMOJI, PROGRESS_EMOJI, SUCCESS_EMOJI, format_bash_with_gutter, warning_message,
+};
pub struct ConfigureResult {
pub shell: Shell,
@@ -173,9 +175,9 @@ pub fn handle_configure_shell(
// Only show advisory if we positively detect it's missing (Some(false)).
// If detection fails (None), stay silent - we can't be sure.
if shell::detect_zsh_compinit() == Some(false) {
- let _ = crate::output::warning(
+ let _ = crate::output::print(warning_message(
"Completions won't work; add to ~/.zshrc before the wt line:",
- );
+ ));
let _ = crate::output::gutter(format_bash_with_gutter(
"autoload -Uz compinit && compinit",
"",
diff --git a/src/commands/hooks.rs b/src/commands/hooks.rs
index 3fd5828fa..d983ef915 100644
--- a/src/commands/hooks.rs
+++ b/src/commands/hooks.rs
@@ -2,7 +2,7 @@ use color_print::cformat;
use worktrunk::HookType;
use worktrunk::config::{CommandConfig, CommandPhase, ProjectConfig};
use worktrunk::git::WorktrunkError;
-use worktrunk::styling::format_bash_with_gutter;
+use worktrunk::styling::{format_bash_with_gutter, progress_message, warning_message};
use super::command_executor::{CommandContext, PreparedCommand, prepare_project_commands};
use crate::commands::process::spawn_detached;
@@ -60,7 +60,7 @@ impl<'a> HookPipeline<'a> {
for prepared in commands {
let label =
crate::commands::format_command_label(label_prefix, prepared.name.as_deref());
- crate::output::progress(format!("{label}:"))?;
+ crate::output::print(progress_message(format!("{label}:")))?;
crate::output::gutter(format_bash_with_gutter(&prepared.expanded, ""))?;
if let Err(err) = execute_command_in_worktree(
@@ -98,7 +98,7 @@ impl<'a> HookPipeline<'a> {
}
None => format!("Command failed: {err_msg}"),
};
- crate::output::warning(message)?;
+ crate::output::print(warning_message(message))?;
// Track first failure to propagate exit code later (only for PostMerge)
if first_failure.is_none() && hook_type == HookType::PostMerge {
@@ -144,7 +144,7 @@ impl<'a> HookPipeline<'a> {
for prepared in commands {
let label =
crate::commands::format_command_label(label_prefix, prepared.name.as_deref());
- crate::output::progress(format!("{label}:"))?;
+ crate::output::print(progress_message(format!("{label}:")))?;
crate::output::gutter(format_bash_with_gutter(&prepared.expanded, ""))?;
let name = prepared.name.as_deref().unwrap_or("cmd");
@@ -162,7 +162,7 @@ impl<'a> HookPipeline<'a> {
Some(name) => format!("Failed to spawn \"{name}\": {err_msg}"),
None => format!("Failed to spawn command: {err_msg}"),
};
- crate::output::warning(message)?;
+ crate::output::print(warning_message(message))?;
}
}
diff --git a/src/commands/list/collect.rs b/src/commands/list/collect.rs
index 64eb18f0a..16997e2a8 100644
--- a/src/commands/list/collect.rs
+++ b/src/commands/list/collect.rs
@@ -22,7 +22,7 @@
use crossbeam_channel as chan;
use rayon::prelude::*;
use worktrunk::git::{LineDiff, Repository, Worktree};
-use worktrunk::styling::INFO_EMOJI;
+use worktrunk::styling::{INFO_EMOJI, warning_message};
use super::ci_status::PrStatus;
use super::model::{
@@ -811,7 +811,7 @@ pub fn collect(
"\n\nThis likely indicates a git command hung. Run with RUST_LOG=debug for details.",
);
- crate::output::warning(diag)?;
+ crate::output::print(warning_message(diag))?;
}
// Finalize progressive table or render buffered output
diff --git a/src/commands/list/collect_progressive_impl.rs b/src/commands/list/collect_progressive_impl.rs
index 4409eb609..7b6f7617d 100644
--- a/src/commands/list/collect_progressive_impl.rs
+++ b/src/commands/list/collect_progressive_impl.rs
@@ -26,6 +26,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use worktrunk::git::{LineDiff, Repository, Worktree};
use worktrunk::path::format_path_for_display;
+use worktrunk::styling::warning_message;
use super::ci_status::PrStatus;
use super::collect::{ExpectedResults, TaskKind, TaskResult, detect_git_operation};
@@ -362,11 +363,11 @@ impl Task for UpstreamTask {
}),
Err(e) => {
if ctx.verbose_errors {
- let _ = output::warning(format!(
+ let _ = output::print(warning_message(format!(
"ahead_behind failed for {}: {}",
format_path_for_display(&ctx.repo_path),
e
- ));
+ )));
}
None
}
@@ -375,11 +376,11 @@ impl Task for UpstreamTask {
Ok(None) => None,
Err(e) => {
if ctx.verbose_errors {
- let _ = output::warning(format!(
+ let _ = output::print(warning_message(format!(
"upstream_branch failed for {}: {}",
format_path_for_display(&ctx.repo_path),
e
- ));
+ )));
}
None
}
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index 5e4d9d77f..84024d39b 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -1,6 +1,7 @@
use worktrunk::HookType;
use worktrunk::config::{Command, CommandPhase, ProjectConfig};
use worktrunk::git::Repository;
+use worktrunk::styling::info_message;
use super::command_approval::approve_command_batch;
use super::command_executor::CommandContext;
@@ -118,7 +119,7 @@ pub fn handle_merge(
// If commands were declined, show message explaining that merge continues anyway
if !approved {
- crate::output::info("Commands declined, continuing merge")?;
+ crate::output::print(info_message("Commands declined, continuing merge"))?;
}
// Handle uncommitted changes (skip if --no-commit) - track whether commit occurred
@@ -251,7 +252,7 @@ fn handle_merge_summary_output(reason: PreserveReason) -> anyhow::Result<()> {
PreserveReason::AlreadyOnTarget => "Worktree preserved (already on target branch)",
PreserveReason::NoRemoveFlag => "Worktree preserved (--no-remove)",
};
- crate::output::info(message)?;
+ crate::output::print(info_message(message))?;
crate::output::flush()?;
Ok(())
diff --git a/src/commands/repository_ext.rs b/src/commands/repository_ext.rs
index 3c76ec8a2..abf93f9a0 100644
--- a/src/commands/repository_ext.rs
+++ b/src/commands/repository_ext.rs
@@ -8,7 +8,7 @@ use color_print::cformat;
use worktrunk::config::ProjectConfig;
use worktrunk::git::{GitError, Repository};
use worktrunk::path::format_path_for_display;
-use worktrunk::styling::format_with_gutter;
+use worktrunk::styling::{format_with_gutter, progress_message, warning_message};
/// CLI-only helpers implemented on [`Repository`] via an extension trait so we can keep orphan
/// implementations inside the binary crate.
@@ -245,10 +245,10 @@ impl RepositoryCliExt for Repository {
nanos
);
- crate::output::progress(cformat!(
+ crate::output::print(progress_message(cformat!(
"Stashing changes in <bold>{}</>...",
format_path_for_display(wt_path)
- ))?;
+ )))?;
let stash_output =
wt_repo.run_command(&["stash", "push", "--include-untracked", "-m", &stash_name])?;
@@ -342,7 +342,9 @@ impl AutoStageWarning {
let count = self.files.len();
let path_word = if count == 1 { "path" } else { "paths" };
- crate::output::warning(format!("Auto-staging {count} untracked {path_word}:"))?;
+ crate::output::print(warning_message(format!(
+ "Auto-staging {count} untracked {path_word}:"
+ )))?;
let joined_files = self.files.join("\n");
crate::output::gutter(format_with_gutter(&joined_files, "", None))?;
@@ -367,20 +369,20 @@ impl TargetWorktreeStash {
}
pub(crate) fn restore(self) -> anyhow::Result<()> {
- crate::output::progress(cformat!(
+ crate::output::print(progress_message(cformat!(
"Restoring stashed changes in <bold>{}</>...",
format_path_for_display(&self.path)
- ))?;
+ )))?;
if let Err(_e) = self
.repo
.run_command(&["stash", "pop", "--quiet", &self.stash_ref])
{
- crate::output::warning(cformat!(
+ crate::output::print(warning_message(cformat!(
"Failed to restore stash <bold>{stash_ref}</> - run <bold>git stash pop {stash_ref}</> in <bold>{path}</>",
stash_ref = self.stash_ref,
path = format_path_for_display(&self.path),
- ))?;
+ )))?;
}
Ok(())
diff --git a/src/commands/standalone.rs b/src/commands/standalone.rs
index 3f619e0b7..7af054749 100644
--- a/src/commands/standalone.rs
+++ b/src/commands/standalone.rs
@@ -2,7 +2,9 @@ use anyhow::Context;
use color_print::cformat;
use worktrunk::HookType;
use worktrunk::git::Repository;
-use worktrunk::styling::format_with_gutter;
+use worktrunk::styling::{
+ format_with_gutter, hint_message, info_message, progress_message, success_message,
+};
use super::commit::{CommitGenerator, CommitOptions};
use super::context::CommandEnv;
@@ -152,9 +154,9 @@ pub fn handle_squash(
.unwrap_or(false);
if skip_pre_commit && has_pre_commit {
- crate::output::hint(cformat!(
+ crate::output::print(hint_message(cformat!(
"Skipping pre-commit hook (<bright-black>--no-verify</>)"
- ))?;
+ )))?;
} else if let Some(ref config) = project_config {
HookPipeline::new(ctx).run_pre_commit(config, Some(&target_branch), auto_trust)?;
}
@@ -224,20 +226,20 @@ pub fn handle_squash(
"Squashing {commit_count} {commit_text}{with_changes} into a single commit <bright-black>({parts_str}</>{paren_close}..."
)
};
- crate::output::progress(squash_progress)?;
+ crate::output::print(progress_message(squash_progress))?;
// Create safety backup before potentially destructive reset if there are working tree changes
if has_staged {
let backup_message = format!("{} β†’ {} (squash)", current_branch, target_branch);
let (sha, _restore_cmd) = repo.create_safety_backup(&backup_message)?;
- crate::output::hint(format!("Backup created @ {sha}"))?;
+ crate::output::print(hint_message(format!("Backup created @ {sha}")))?;
}
// Get commit subjects for the squash message
let subjects = repo.commit_subjects(&range)?;
// Generate squash commit message
- crate::output::progress("Generating squash commit message...")?;
+ crate::output::print(progress_message("Generating squash commit message..."))?;
generator.emit_hint_if_needed()?;
@@ -267,9 +269,9 @@ pub fn handle_squash(
// Check if there are actually any changes to commit
if !repo.has_staged_changes()? {
- crate::output::info(format!(
+ crate::output::print(info_message(format!(
"No changes after squashing {commit_count} {commit_text}"
- ))?;
+ )))?;
return Ok(SquashResult::NoNetChanges);
}
@@ -284,7 +286,9 @@ pub fn handle_squash(
.to_string();
// Show success immediately after completing the squash
- crate::output::success(cformat!("Squashed @ <dim>{commit_hash}</>"))?;
+ crate::output::print(success_message(cformat!(
+ "Squashed @ <dim>{commit_hash}</>"
+ )))?;
Ok(SquashResult::Squashed)
}
@@ -322,7 +326,9 @@ pub fn handle_rebase(target: Option<&str>) -> anyhow::Result<RebaseResult> {
// Only show progress for true rebases (fast-forwards are instant)
if !is_fast_forward {
- crate::output::progress(cformat!("Rebasing onto <bold>{target_branch}</>..."))?;
+ crate::output::print(progress_message(cformat!(
+ "Rebasing onto <bold>{target_branch}</>..."
+ )))?;
}
let rebase_result = repo.run_command(&["rebase", &target_branch]);
@@ -359,9 +365,13 @@ pub fn handle_rebase(target: Option<&str>) -> anyhow::Result<RebaseResult> {
// Success
if is_fast_forward {
- crate::output::success(cformat!("Fast-forwarded to <bold>{target_branch}</>"))?;
+ crate::output::print(success_message(cformat!(
+ "Fast-forwarded to <bold>{target_branch}</>"
+ )))?;
} else {
- crate::output::success(cformat!("Rebased onto <bold>{target_branch}</>"))?;
+ crate::output::print(success_message(cformat!(
+ "Rebased onto <bold>{target_branch}</>"
+ )))?;
}
Ok(RebaseResult::Rebased)
@@ -390,7 +400,7 @@ pub fn handle_standalone_add_approvals(force: bool, show_all: bool) -> anyhow::R
let commands = collect_commands_for_hooks(&project_config, &all_hooks);
if commands.is_empty() {
- crate::output::info("No commands configured in project")?;
+ crate::output::print(info_message("No commands configured in project"))?;
return Ok(());
}
@@ -402,7 +412,7 @@ pub fn handle_standalone_add_approvals(force: bool, show_all: bool) -> anyhow::R
.collect();
if unapproved.is_empty() {
- crate::output::info("All commands already approved")?;
+ crate::output::print(info_message("All commands already approved"))?;
return Ok(());
}
@@ -421,13 +431,13 @@ pub fn handle_standalone_add_approvals(force: bool, show_all: bool) -> anyhow::R
if approved {
if force {
// When using --force, commands aren't saved to config
- crate::output::success("Commands approved; not saved (--force)")?;
+ crate::output::print(success_message("Commands approved; not saved (--force)"))?;
} else {
// Interactive approval - commands were saved to config (unless save failed)
- crate::output::success("Commands approved & saved to config")?;
+ crate::output::print(success_message("Commands approved & saved to config"))?;
}
} else {
- crate::output::info("Commands declined")?;
+ crate::output::print(info_message("Commands declined"))?;
}
Ok(())
@@ -444,17 +454,17 @@ pub fn handle_standalone_clear_approvals(global: bool) -> anyhow::Result<()> {
let project_count = config.projects.len();
if project_count == 0 {
- crate::output::info("No approvals to clear")?;
+ crate::output::print(info_message("No approvals to clear"))?;
return Ok(());
}
config.projects.clear();
config.save().context("Failed to save config")?;
- crate::output::success(format!(
+ crate::output::print(success_message(format!(
"Cleared approvals for {project_count} project{}",
if project_count == 1 { "" } else { "s" }
- ))?;
+ )))?;
} else {
// Clear approvals for current project (default)
let repo = Repository::current();
@@ -464,7 +474,7 @@ pub fn handle_standalone_clear_approvals(global: bool) -> anyhow::Result<()> {
let had_approvals = config.projects.contains_key(&project_id);
if !had_approvals {
- crate::output::info("No approvals to clear for this project")?;
+ crate::output::print(info_message("No approvals to clear for this project"))?;
return Ok(());
}
@@ -479,10 +489,10 @@ pub fn handle_standalone_clear_approvals(global: bool) -> anyhow::Result<()> {
.revoke_project(&project_id)
.context("Failed to clear project approvals")?;
- crate::output::success(format!(
+ crate::output::print(success_message(format!(
"Cleared {approval_count} approval{} for this project",
if approval_count == 1 { "" } else { "s" }
- ))?;
+ )))?;
}
Ok(())
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index 2d38ffbc0..ab817478c 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -1,5 +1,7 @@
//! Worktree operations with dual-mode output for shell integration.
//!
+//! Note: This module uses message functions from worktrunk::styling.
+//!
//! # The Directory Change Problem
//!
//! Worktree commands (`switch`, `remove`, `merge`) need to change the user's working directory,
@@ -114,7 +116,10 @@ use std::path::PathBuf;
use worktrunk::HookType;
use worktrunk::config::{CommandPhase, WorktrunkConfig};
use worktrunk::git::{GitError, Repository, ResolvedWorktree, is_command_not_approved};
-use worktrunk::styling::format_with_gutter;
+use worktrunk::styling::{
+ format_with_gutter, hint_message, info_message, progress_message, success_message,
+ warning_message,
+};
use super::command_executor::CommandContext;
use super::hooks::{HookFailureStrategy, HookPipeline};
@@ -324,18 +329,20 @@ pub fn handle_switch(
let remotes = repo.remotes_with_branch(&resolved_branch)?;
if !remotes.is_empty() {
let remote_ref = format!("{}/{}", remotes[0], resolved_branch);
- crate::output::warning(cformat!(
+ crate::output::print(warning_message(cformat!(
"Branch <bold>{resolved_branch}</> exists on remote ({remote_ref}); creating new branch from base instead"
- ))?;
- crate::output::hint(cformat!(
+ )))?;
+ crate::output::print(hint_message(cformat!(
"Use <bright-black>wt switch {resolved_branch}</> (without <bright-black>--create</>) to switch to the remote branch"
- ))?;
+ )))?;
}
}
// Check if base flag was provided without create flag
if resolved_base.is_some() && !create {
- crate::output::warning("--base flag is only used with --create, ignoring")?;
+ crate::output::print(warning_message(
+ "--base flag is only used with --create, ignoring",
+ ))?;
}
// Compute expected worktree path for this branch
@@ -492,7 +499,9 @@ pub fn handle_switch(
// Only treat CommandNotApproved as non-fatal (user declined)
// Other errors should still fail
if is_command_not_approved(&e) {
- crate::output::info("Commands declined, continuing worktree creation")?;
+ crate::output::print(info_message(
+ "Commands declined, continuing worktree creation",
+ ))?;
} else {
return Err(e);
}
@@ -526,9 +535,9 @@ pub fn handle_remove(
// Show progress (unless running in background - output handler will show command)
if !background {
- crate::output::progress(cformat!(
+ crate::output::print(progress_message(cformat!(
"Removing worktree for <bold>{worktree_name}</>..."
- ))?;
+ )))?;
}
repo.remove_worktree_by_name(worktree_name, no_delete_branch, force_delete)
@@ -547,7 +556,7 @@ pub fn handle_remove_current(
// Show progress (unless running in background - output handler will show command)
if !background {
- crate::output::progress("Removing current worktree...")?;
+ crate::output::print(progress_message("Removing current worktree..."))?;
}
repo.remove_current_worktree(no_delete_branch, force_delete)
@@ -567,10 +576,10 @@ pub fn handle_remove_by_path(
let repo = Repository::current();
if !background {
- crate::output::progress(cformat!(
+ crate::output::print(progress_message(cformat!(
"Removing worktree at <bold>{}</>...",
worktrunk::path::format_path_for_display(path)
- ))?;
+ )))?;
}
// Check that the worktree is clean
@@ -772,9 +781,9 @@ pub fn handle_push(
format!(" ({})", notes.join(", "))
};
- crate::output::progress(cformat!(
+ crate::output::print(progress_message(cformat!(
"{verb_ing} {commit_count} {commit_text} to <bold>{target_branch}</> @ <dim>{head_sha}</>{operations_note}"
- ))?;
+ )))?;
// Show the commit graph with color
let log_output = repo.run_command(&[
@@ -829,10 +838,10 @@ pub fn handle_push(
// Re-apply bright-black after stats (which end with a reset) so ) is also gray
let stats_str = summary_parts.join(", ");
let paren_close = cformat!("<bright-black>)</>"); // Separate to avoid cformat optimization
- crate::output::success(cformat!(
+ crate::output::print(success_message(cformat!(
"{verb} <bold>{target_branch}</> <bright-black>({stats_str}</>{}",
paren_close
- ))?;
+ )))?;
} else {
// For merge workflow context, explain why nothing was pushed
let context = if let Some(ops) = operations {
@@ -853,9 +862,9 @@ pub fn handle_push(
};
// No action: nothing was pushed, just acknowledging state
- crate::output::info(cformat!(
+ crate::output::print(info_message(cformat!(
"Already up to date with <bold>{target_branch}</>{context}"
- ))?;
+ )))?;
}
Ok(())
diff --git a/src/git/error.rs b/src/git/error.rs
index 005ec209a..5ce7fe636 100644
--- a/src/git/error.rs
+++ b/src/git/error.rs
@@ -15,7 +15,9 @@ use color_print::{cformat, cwrite};
use super::HookType;
use crate::path::format_path_for_display;
-use crate::styling::{ERROR_EMOJI, HINT_EMOJI, INFO_EMOJI, format_with_gutter};
+use crate::styling::{
+ ERROR_EMOJI, HINT_EMOJI, error_message, format_with_gutter, hint_message, info_message,
+};
/// Domain errors for git and worktree operations.
///
@@ -134,9 +136,13 @@ impl std::fmt::Display for GitError {
Some(action) => format!("Cannot {action}: not on a branch (detached HEAD)"),
None => "Not on a branch (detached HEAD)".to_string(),
};
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>{message}</>\n\n{HINT_EMOJI} <dim>Switch to a branch first with </>git switch <<branch>>"
+ "{}\n\n{}",
+ error_message(&message),
+ hint_message(cformat!(
+ "Switch to a branch first with <bright-black>git switch <<branch>></>"
+ ))
)
}
@@ -153,37 +159,52 @@ impl std::fmt::Display for GitError {
}
(None, None) => cformat!("Working tree has uncommitted changes"),
};
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>{message}</>\n\n{HINT_EMOJI} <dim>Commit or stash changes first</>"
+ "{}\n\n{}",
+ error_message(&message),
+ hint_message("Commit or stash changes first")
)
}
GitError::BranchAlreadyExists { branch } => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Branch <bold>{branch}</> already exists</>\n\n{HINT_EMOJI} <dim>Remove <bright-black>--create</> flag to switch to the existing branch</>"
+ "{}\n\n{}",
+ error_message(cformat!("Branch <bold>{branch}</> already exists")),
+ hint_message(cformat!(
+ "Remove <bright-black>--create</> flag to switch to the existing branch"
+ ))
)
}
GitError::InvalidReference { reference } => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Branch <bold>{reference}</> not found</>\n\n{HINT_EMOJI} <dim>Use <bright-black>--create</> to create a new branch, or <bright-black>wt list --branches --remotes</> for available branches</>"
+ "{}\n\n{}",
+ error_message(cformat!("Branch <bold>{reference}</> not found")),
+ hint_message(cformat!(
+ "Use <bright-black>--create</> to create a new branch, or <bright-black>wt list --branches --remotes</> for available branches"
+ ))
)
}
GitError::WorktreeMissing { branch } => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Worktree directory missing for <bold>{branch}</></>\n\n{HINT_EMOJI} <dim>Run <bright-black>git worktree prune</> to clean up</>"
+ "{}\n\n{}",
+ error_message(cformat!("Worktree directory missing for <bold>{branch}</>")),
+ hint_message(cformat!(
+ "Run <bright-black>git worktree prune</> to clean up"
+ ))
)
}
GitError::NoWorktreeFound { branch } => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>No worktree found for branch <bold>{branch}</></>"
+ "{}",
+ error_message(cformat!("No worktree found for branch <bold>{branch}</>"))
)
}
@@ -200,24 +221,34 @@ impl std::fmt::Display for GitError {
occupant,
} => {
let path_display = format_path_for_display(path);
- if let Some(occupant_branch) = occupant {
- cwrite!(
- f,
- "{ERROR_EMOJI} <red>Cannot create worktree for <bold>{branch}</>: target path already exists</>\n\n{HINT_EMOJI} <dim>Reuse the existing worktree at {path_display} (currently on <bold>{occupant_branch}</>) or remove the directory before retrying</>"
- )
+ let hint = if let Some(occupant_branch) = occupant {
+ hint_message(cformat!(
+ "Reuse the existing worktree at {path_display} (currently on <bold>{occupant_branch}</>) or remove the directory before retrying"
+ ))
} else {
- cwrite!(
- f,
- "{ERROR_EMOJI} <red>Cannot create worktree for <bold>{branch}</>: target path already exists</>\n\n{HINT_EMOJI} <dim>Reuse the existing worktree at {path_display} or remove the directory before retrying</>"
- )
- }
+ hint_message(format!(
+ "Reuse the existing worktree at {path_display} or remove the directory before retrying"
+ ))
+ };
+ write!(
+ f,
+ "{}\n\n{}",
+ error_message(cformat!(
+ "Cannot create worktree for <bold>{branch}</>: target path already exists"
+ )),
+ hint
+ )
}
GitError::WorktreePathExists { path } => {
let path_display = format_path_for_display(path);
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Directory already exists: <bold>{path_display}</></>\n\n{HINT_EMOJI} <dim>Remove the directory or use a different branch name</>"
+ "{}\n\n{}",
+ error_message(cformat!(
+ "Directory already exists: <bold>{path_display}</>"
+ )),
+ hint_message("Remove the directory or use a different branch name")
)
}
@@ -228,9 +259,15 @@ impl std::fmt::Display for GitError {
} => {
let expected = format_path_for_display(expected_path);
let actual = format_path_for_display(actual_path);
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Ambiguous: <bold>{expected}</> has a worktree on a different branch, but branch <bold>{branch}</> exists at <bold>{actual}</></>\n\n{HINT_EMOJI} <dim>Use <bright-black>wt list</> to see worktree-branch mappings</>"
+ "{}\n\n{}",
+ error_message(cformat!(
+ "Ambiguous: <bold>{expected}</> has a worktree on a different branch, but branch <bold>{branch}</> exists at <bold>{actual}</>"
+ )),
+ hint_message(cformat!(
+ "Use <bright-black>wt list</> to see worktree-branch mappings"
+ ))
)
}
@@ -240,13 +277,11 @@ impl std::fmt::Display for GitError {
error,
} => {
let header = if let Some(base) = base_branch {
- cformat!(
- "{ERROR_EMOJI} <red>Failed to create worktree for <bold>{branch}</> from base <bold>{base}</></>"
- )
+ error_message(cformat!(
+ "Failed to create worktree for <bold>{branch}</> from base <bold>{base}</>"
+ ))
} else {
- cformat!(
- "{ERROR_EMOJI} <red>Failed to create worktree for <bold>{branch}</></>"
- )
+ error_message(cformat!("Failed to create worktree for <bold>{branch}</>"))
};
write!(f, "{}", format_error_block(header, error))
}
@@ -257,16 +292,17 @@ impl std::fmt::Display for GitError {
error,
} => {
let path_display = format_path_for_display(path);
- let header = cformat!(
- "{ERROR_EMOJI} <red>Failed to remove worktree for <bold>{branch}</> at <bold>{path_display}</></>"
- );
+ let header = error_message(cformat!(
+ "Failed to remove worktree for <bold>{branch}</> at <bold>{path_display}</>"
+ ));
write!(f, "{}", format_error_block(header, error))
}
GitError::CannotRemoveMainWorktree => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>The main worktree cannot be removed</>"
+ "{}",
+ error_message("The main worktree cannot be removed")
)
}
@@ -274,18 +310,22 @@ impl std::fmt::Display for GitError {
files,
worktree_path,
} => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Cannot push: conflicting uncommitted changes in:</>\n\n"
+ "{}\n\n",
+ error_message("Cannot push: conflicting uncommitted changes in:")
)?;
if !files.is_empty() {
let joined_files = files.join("\n");
write!(f, "{}", format_with_gutter(&joined_files, "", None))?;
}
let path_display = format_path_for_display(worktree_path);
- cwrite!(
+ write!(
f,
- "\n{HINT_EMOJI} <dim>Commit or stash these changes in {path_display} first</>"
+ "\n{}",
+ hint_message(format!(
+ "Commit or stash these changes in {path_display} first"
+ ))
)
}
@@ -294,31 +334,44 @@ impl std::fmt::Display for GitError {
commits_formatted,
in_merge_context,
} => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Can't push to local <bold>{target_branch}</> branch: it has newer commits</>"
+ "{}",
+ error_message(cformat!(
+ "Can't push to local <bold>{target_branch}</> branch: it has newer commits"
+ ))
)?;
if !commits_formatted.is_empty() {
write!(f, "\n{}", format_with_gutter(commits_formatted, "", None))?;
}
// Context-appropriate hint
if *in_merge_context {
- cwrite!(
+ write!(
f,
- "\n{HINT_EMOJI} <dim>Run <bright-black>wt merge</> again to incorporate these changes</>"
+ "\n{}",
+ hint_message(cformat!(
+ "Run <bright-black>wt merge</> again to incorporate these changes"
+ ))
)
} else {
- cwrite!(
+ write!(
f,
- "\n{HINT_EMOJI} <dim>Use <bright-black>wt step rebase</> or <bright-black>wt merge</> to rebase onto <bold>{target_branch}</></>"
+ "\n{}",
+ hint_message(cformat!(
+ "Use <bright-black>wt step rebase</> or <bright-black>wt merge</> to rebase onto <bold>{target_branch}</>"
+ ))
)
}
}
GitError::MergeCommitsFound => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Found merge commits in push range</>\n\n{HINT_EMOJI} <dim>Use <bright-black>--allow-merge-commits</> to push non-linear history</>"
+ "{}\n\n{}",
+ error_message("Found merge commits in push range"),
+ hint_message(cformat!(
+ "Use <bright-black>--allow-merge-commits</> to push non-linear history"
+ ))
)
}
@@ -326,59 +379,72 @@ impl std::fmt::Display for GitError {
target_branch,
git_output,
} => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Rebase onto <bold>{target_branch}</> incomplete</>"
+ "{}",
+ error_message(cformat!("Rebase onto <bold>{target_branch}</> incomplete"))
)?;
if !git_output.is_empty() {
write!(f, "\n{}", format_with_gutter(git_output, "", None))
} else {
- cwrite!(
+ write!(
f,
- "\n\n{HINT_EMOJI} <dim>Resolve conflicts and run <bright-black>git rebase --continue</></>\n{HINT_EMOJI} <dim>Or abort with <bright-black>git rebase --abort</></>"
+ "\n\n{}\n{}",
+ hint_message(cformat!(
+ "Resolve conflicts and run <bright-black>git rebase --continue</>"
+ )),
+ hint_message(cformat!(
+ "Or abort with <bright-black>git rebase --abort</>"
+ ))
)
}
}
GitError::PushFailed { error } => {
- let header = cformat!("{ERROR_EMOJI} <red>Push failed</>");
+ let header = error_message("Push failed");
write!(f, "{}", format_error_block(header, error))
}
GitError::NotInteractive => {
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>Cannot prompt for approval in non-interactive environment</>\n\n{HINT_EMOJI} <dim>In CI/CD, use <bright-black>--force</> to skip prompts. To pre-approve commands, use <bright-black>wt config approvals add</></>"
+ "{}\n\n{}",
+ error_message("Cannot prompt for approval in non-interactive environment"),
+ hint_message(cformat!(
+ "In CI/CD, use <bright-black>--force</> to skip prompts. To pre-approve commands, use <bright-black>wt config approvals add</>"
+ ))
)
}
GitError::LlmCommandFailed { command, error } => {
- let error_header =
- cformat!("{ERROR_EMOJI} <red>Commit generation command failed</>");
+ let error_header = error_message("Commit generation command failed");
let error_block = format_error_block(error_header, error);
let command_gutter = format_with_gutter(command, "", None);
write!(
f,
- "{}\n\n{INFO_EMOJI} Ran command:\n{}",
+ "{}\n\n{}\n{}",
error_block.trim_end(),
+ info_message("Ran command:"),
command_gutter.trim_end()
)
}
GitError::ProjectConfigNotFound { config_path } => {
let path_display = format_path_for_display(config_path);
- cwrite!(
+ write!(
f,
- "{ERROR_EMOJI} <red>No project configuration found</>\n\n{HINT_EMOJI} <dim>Create a config file at: <bold>{path_display}</></>"
+ "{}\n\n{}",
+ error_message("No project configuration found"),
+ hint_message(cformat!("Create a config file at: <bold>{path_display}</>"))
)
}
GitError::ParseError { message } => {
- cwrite!(f, "{ERROR_EMOJI} <red>{message}</>")
+ write!(f, "{}", error_message(message))
}
GitError::Other { message } => {
- cwrite!(f, "{ERROR_EMOJI} <red>{message}</>")
+ write!(f, "{}", error_message(message))
}
}
}
@@ -407,7 +473,7 @@ impl std::fmt::Display for WorktrunkError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
WorktrunkError::ChildProcessExited { message, .. } => {
- cwrite!(f, "{ERROR_EMOJI} <red>{message}</>")
+ write!(f, "{}", error_message(message))
}
WorktrunkError::HookCommandFailed {
hook_type,
@@ -415,17 +481,21 @@ impl std::fmt::Display for WorktrunkError {
error,
..
} => {
- if let Some(name) = command_name {
- cwrite!(
- f,
- "{ERROR_EMOJI} <red>{hook_type} command failed: <bold>{name}</>: {error}</>\n\n{HINT_EMOJI} <dim>Use <bright-black>--no-verify</> to skip {hook_type} commands</>"
- )
+ let err_msg = if let Some(name) = command_name {
+ error_message(cformat!(
+ "{hook_type} command failed: <bold>{name}</>: {error}"
+ ))
} else {
- cwrite!(
- f,
- "{ERROR_EMOJI} <red>{hook_type} command failed: {error}</>\n\n{HINT_EMOJI} <dim>Use <bright-black>--no-verify</> to skip {hook_type} commands</>"
- )
- }
+ error_message(format!("{hook_type} command failed: {error}"))
+ };
+ write!(
+ f,
+ "{}\n\n{}",
+ err_msg,
+ hint_message(cformat!(
+ "Use <bright-black>--no-verify</> to skip {hook_type} commands"
+ ))
+ )
}
WorktrunkError::CommandNotApproved => {
Ok(()) // on_skip callback handles the printing
diff --git a/src/main.rs b/src/main.rs
index 1948ba2e6..fa18e9eef 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,7 +6,9 @@ use std::process;
use worktrunk::config::{WorktrunkConfig, set_config_path};
use worktrunk::git::{Repository, exit_code, is_command_not_approved, set_base_path};
use worktrunk::path::format_path_for_display;
-use worktrunk::styling::{format_with_gutter, println};
+use worktrunk::styling::{
+ format_with_gutter, hint_message, info_message, println, success_message, warning_message,
+};
mod cli;
mod commands;
@@ -506,10 +508,10 @@ fn main() {
// which is handled internally by prompt_for_confirmation()
match result.action {
ConfigAction::Added | ConfigAction::Created => {
- crate::output::success(message)?;
+ crate::output::print(success_message(message))?;
}
ConfigAction::AlreadyExists => {
- crate::output::info(message)?;
+ crate::output::print(info_message(message))?;
}
ConfigAction::WouldAdd | ConfigAction::WouldCreate => {
unreachable!("Preview actions handled by confirmation prompt")
@@ -528,10 +530,10 @@ fn main() {
);
match comp_result.action {
ConfigAction::Added | ConfigAction::Created => {
- crate::output::success(comp_message)?;
+ crate::output::print(success_message(comp_message))?;
}
ConfigAction::AlreadyExists => {
- crate::output::info(comp_message)?;
+ crate::output::print(info_message(comp_message))?;
}
ConfigAction::WouldAdd | ConfigAction::WouldCreate => {
unreachable!("Preview actions handled by confirmation prompt")
@@ -543,9 +545,9 @@ fn main() {
// Show skipped shells
for (shell, path) in &scan_result.skipped {
let path = format_path_for_display(path);
- crate::output::hint(cformat!(
+ crate::output::print(hint_message(cformat!(
"Skipped <bright-black>{shell}</>; {path} not found"
- ))?;
+ )))?;
}
// Exit with error if no shells configured
@@ -560,12 +562,12 @@ fn main() {
if shells_configured_count > 0 {
crate::output::blank()?;
let plural = if shells_configured_count == 1 { "" } else { "s" };
- crate::output::success(format!(
+ crate::output::print(success_message(format!(
"Configured {shells_configured_count} shell{plural}"
- ))?;
+ )))?;
} else {
// No action: all shells were already configured
- crate::output::success("All shells already configured")?;
+ crate::output::print(success_message("All shells already configured"))?;
}
// Restart hint: only shown if the current shell's extension changed
@@ -594,12 +596,12 @@ fn main() {
// Fish auto-sources from conf.d, so just say "Restart shell"
// Bash/Zsh can source directly for immediate activation
if matches!(result.shell, worktrunk::shell::Shell::Fish) {
- crate::output::hint("Restart shell to activate")?;
+ crate::output::print(hint_message("Restart shell to activate"))?;
} else {
let path = format_path_for_display(&result.path);
- crate::output::hint(format!(
+ crate::output::print(hint_message(format!(
"Restart shell or run: source {path}"
- ))?;
+ )))?;
}
}
}
@@ -630,10 +632,10 @@ fn main() {
"shell extension"
};
- crate::output::success(cformat!(
+ crate::output::print(success_message(cformat!(
"{} {what} for <bold>{shell}</> @ <bold>{path}</>",
result.action.description(),
- ))?;
+ )))?;
}
// Show completion results
@@ -641,10 +643,10 @@ fn main() {
let shell = result.shell;
let path = format_path_for_display(&result.path);
- crate::output::success(cformat!(
+ crate::output::print(success_message(cformat!(
"{} completions for <bold>{shell}</> @ <bold>{path}</>",
result.action.description(),
- ))?;
+ )))?;
}
// Show not found - warning if explicit shell, hint if auto-scan
@@ -661,13 +663,13 @@ fn main() {
"shell extension"
};
if explicit_shell {
- crate::output::warning(format!(
+ crate::output::print(warning_message(format!(
"No {what} found in {path}"
- ))?;
+ )))?;
} else {
- crate::output::hint(cformat!(
+ crate::output::print(hint_message(cformat!(
"No <bright-black>{shell}</> {what} in {path}"
- ))?;
+ )))?;
}
}
@@ -682,13 +684,13 @@ fn main() {
}
let path = format_path_for_display(path);
if explicit_shell {
- crate::output::warning(format!(
+ crate::output::print(warning_message(format!(
"No completions found in {path}"
- ))?;
+ )))?;
} else {
- crate::output::hint(cformat!(
+ crate::output::print(hint_message(cformat!(
"No <bright-black>{shell}</> completions in {path}"
- ))?;
+ )))?;
}
}
@@ -698,9 +700,9 @@ fn main() {
if total_changes == 0 {
if all_not_found == 0 {
crate::output::blank()?;
- crate::output::hint(
+ crate::output::print(hint_message(
"No shell integration found to remove",
- )?;
+ ))?;
}
return Ok(());
}
@@ -708,9 +710,9 @@ fn main() {
// Summary
crate::output::blank()?;
let plural = if shell_count == 1 { "" } else { "s" };
- crate::output::success(format!(
+ crate::output::print(success_message(format!(
"Removed integration from {shell_count} shell{plural}"
- ))?;
+ )))?;
// Hint about restarting shell (only if current shell was affected)
let current_shell = std::env::var("SHELL")
@@ -725,7 +727,9 @@ fn main() {
});
if current_shell_affected {
- crate::output::hint("Restart shell to complete uninstall")?;
+ crate::output::print(hint_message(
+ "Restart shell to complete uninstall",
+ ))?;
}
Ok(())
})
@@ -780,12 +784,14 @@ fn main() {
match handle_squash(target.as_deref(), force, !verify, false, stage_final)? {
SquashResult::Squashed | SquashResult::NoNetChanges => {}
SquashResult::NoCommitsAhead(branch) => {
- crate::output::info(format!(
+ crate::output::print(info_message(format!(
"Nothing to squash; no commits ahead of {branch}"
- ))?;
+ )))?;
}
SquashResult::AlreadySingleCommit => {
- crate::output::info("Nothing to squash; already a single commit")?;
+ crate::output::print(info_message(
+ "Nothing to squash; already a single commit",
+ ))?;
}
}
Ok(())
@@ -798,7 +804,9 @@ fn main() {
handle_rebase(target.as_deref()).and_then(|result| match result {
RebaseResult::Rebased => Ok(()),
RebaseResult::UpToDate(branch) => {
- crate::output::info(format!("Already up-to-date with {branch}"))?;
+ crate::output::print(info_message(format!(
+ "Already up-to-date with {branch}"
+ )))?;
Ok(())
}
})
diff --git a/src/output/global.rs b/src/output/global.rs
index 92323fc4c..af2c07d7e 100644
--- a/src/output/global.rs
+++ b/src/output/global.rs
@@ -61,61 +61,25 @@ pub fn initialize(mode: OutputMode) {
});
}
-/// Emit a success message
-pub fn success(message: impl Into<String>) -> io::Result<()> {
- with_output(|h| h.success(message.into()))
-}
-
-/// Emit a progress message
-///
-/// Progress messages are intermediate status updates like "πŸ”„ Cleaning up worktree..."
-/// They are shown to users in both modes (users need to see what's happening).
-pub fn progress(message: impl Into<String>) -> io::Result<()> {
- with_output(|h| h.progress(message.into()))
-}
-
-/// Display a hint message
-///
-/// Hints are suggestions for users, like "Backup created @ \<sha\>" or "Using fallback commit message"
-pub fn hint(message: impl Into<String>) -> io::Result<()> {
- with_output(|h| h.hint(message.into()))
-}
-
/// Display a shell integration hint (suppressed in directive mode)
///
/// Shell integration hints like "Run `wt config shell install` to enable automatic cd" are only
-/// shown in interactive mode since directive mode users already have shell integration
+/// shown in interactive mode since directive mode users already have shell integration.
+///
+/// This is kept as a separate method because it has mode-specific behavior.
pub fn shell_integration_hint(message: impl Into<String>) -> io::Result<()> {
with_output(|h| h.shell_integration_hint(message.into()))
}
-/// Emit an info message
-///
-/// Info messages are neutral status updates like "βšͺ No changes detected"
-/// They use INFO_EMOJI (βšͺ) and dimmed styling.
-pub fn info(message: impl Into<String>) -> io::Result<()> {
- with_output(|h| h.info(message.into()))
-}
-
-/// Emit a warning message
-///
-/// Warning messages are non-blocking issues like "🟑 Uncommitted changes detected"
-/// They use WARNING_EMOJI (🟑) and warning styling.
-pub fn warning(message: impl Into<String>) -> io::Result<()> {
- with_output(|h| h.warning(message.into()))
-}
-
-/// Emit an error message
-///
-/// Error messages indicate failures like "❌ Failed to delete branch"
-/// They use ERROR_EMOJI (❌) and red styling.
-pub fn error(message: impl Into<String>) -> io::Result<()> {
- with_output(|h| h.error(message.into()))
-}
-
/// Print a message (written as-is)
///
-/// The caller is responsible for formatting.
+/// Use with message formatting functions for semantic output:
+/// ```ignore
+/// use worktrunk::styling::{error_message, success_message, hint_message};
+/// output::print(error_message("Failed to create branch"))?;
+/// output::print(success_message("Branch created"))?;
+/// output::print(hint_message("Use --force to override"))?;
+/// ```
pub fn print(message: impl Into<String>) -> io::Result<()> {
with_output(|h| h.print(message.into()))
}
diff --git a/src/output/handlers.rs b/src/output/handlers.rs
index 02643b41a..d5f9dd797 100644
--- a/src/output/handlers.rs
+++ b/src/output/handlers.rs
@@ -12,7 +12,10 @@ use worktrunk::git::GitError;
use worktrunk::git::Repository;
use worktrunk::path::format_path_for_display;
use worktrunk::shell::Shell;
-use worktrunk::styling::{HINT_EMOJI, format_with_gutter};
+use worktrunk::styling::{
+ HINT_EMOJI, error_message, format_with_gutter, info_message, progress_message, success_message,
+ warning_message,
+};
/// Format a switch success message with a consistent location phrase
///
@@ -143,9 +146,9 @@ fn handle_branch_deletion_result(
Ok(Some(reason)) => Ok(Some(reason)), // Deleted (with or without integration reason)
Ok(None) => {
// Branch not integrated - we chose not to delete (not a failure)
- super::info(cformat!(
+ super::print(info_message(cformat!(
"Branch <bold>{branch_name}</> retained; has unmerged changes"
- ))?;
+ )))?;
super::print(cformat!(
"{HINT_EMOJI} <dim>Use </>wt remove -D<dim> to delete unmerged branches</>"
))?;
@@ -153,7 +156,9 @@ fn handle_branch_deletion_result(
}
Err(e) => {
// Git command failed - this is an error (we decided to delete but couldn't)
- super::error(cformat!("Failed to delete branch <bold>{branch_name}</>"))?;
+ super::print(error_message(cformat!(
+ "Failed to delete branch <bold>{branch_name}</>"
+ )))?;
super::gutter(format_with_gutter(&e.to_string(), "", None))?;
Err(e)
}
@@ -264,10 +269,10 @@ pub fn handle_switch_output(
match result {
SwitchResult::AlreadyAt(path) => {
// Already at target - show info, no hint needed
- super::info(cformat!(
+ super::print(info_message(cformat!(
"Already on worktree for <bold>{branch}</> at <bold>{}</>",
format_path_for_display(path)
- ))?;
+ )))?;
}
SwitchResult::Existing(path) => {
// Check if we can cd or if shell integration is at least configured
@@ -275,15 +280,15 @@ pub fn handle_switch_output(
if is_directive_mode || has_execute_command || is_configured {
// Shell integration active, --execute provided, or configured - show success
- super::success(format_switch_success_message(
+ super::print(success_message(format_switch_success_message(
branch, path, false, None, None,
- ))?;
+ )))?;
} else {
// Shell integration not configured - show warning and setup hint
let path_display = format_path_for_display(path);
- super::warning(cformat!(
+ super::print(warning_message(cformat!(
"Worktree for <bold>{branch}</> at <bold>{path_display}</>; cannot cd (no shell integration)"
- ))?;
+ )))?;
super::shell_integration_hint(shell_integration_hint())?;
}
}
@@ -294,13 +299,13 @@ pub fn handle_switch_output(
from_remote,
} => {
// Creation succeeded - show success
- super::success(format_switch_success_message(
+ super::print(success_message(format_switch_success_message(
branch,
path,
*created_branch,
base_branch.as_deref(),
from_remote.as_deref(),
- ))?;
+ )))?;
// Show setup hint if shell integration not active
if !is_directive_mode && !has_execute_command {
super::shell_integration_hint(shell_integration_hint())?;
@@ -319,7 +324,7 @@ pub fn execute_user_command(command: &str) -> anyhow::Result<()> {
use worktrunk::styling::format_bash_with_gutter;
// Show what command is being executed (section header + gutter content)
- super::progress("Executing (--execute):")?;
+ super::print(progress_message("Executing (--execute):"))?;
super::gutter(format_bash_with_gutter(command, ""))?;
super::execute(command)?;
@@ -405,9 +410,9 @@ fn handle_branch_only_output(
force_delete: bool,
) -> anyhow::Result<()> {
// Warn that no worktree was found (user asked to remove it)
- super::warning(cformat!(
+ super::print(warning_message(cformat!(
"No worktree found for branch <bold>{branch_name}</>"
- ))?;
+ )))?;
// Attempt branch deletion (unless --no-delete-branch was specified)
if no_delete_branch {
@@ -433,7 +438,9 @@ fn handle_branch_only_output(
integration_reason,
default_branch.as_deref(),
);
- super::success(cformat!("Removed branch <bold>{branch_name}</>{flag_note}"))?;
+ super::print(success_message(cformat!(
+ "Removed branch <bold>{branch_name}</>{flag_note}"
+ )))?;
}
super::flush()?;
@@ -483,9 +490,9 @@ fn handle_removed_worktree_output(
let Some(branch_name) = branch_name else {
// No branch associated - just remove the worktree
if background {
- super::progress(
+ super::print(progress_message(
"Removing worktree in background (detached HEAD, no branch to delete)",
- )?;
+ ))?;
let remove_command = build_remove_command(worktree_path, None);
spawn_detached(
&repo,
@@ -506,7 +513,9 @@ fn handle_removed_worktree_output(
}
.into());
}
- super::success("Removed worktree (detached HEAD, no branch to delete)")?;
+ super::print(success_message(
+ "Removed worktree (detached HEAD, no branch to delete)",
+ ))?;
}
super::flush()?;
return Ok(());
@@ -561,7 +570,7 @@ fn handle_removed_worktree_output(
"<cyan>Removing <bold>{branch_name}</> worktree in background; retaining unmerged branch</>"
)
};
- super::progress(action)?;
+ super::print(progress_message(action))?;
// Show hint for unmerged branches (same as synchronous path)
if !no_delete_branch && !should_delete_branch {
@@ -616,7 +625,7 @@ fn handle_removed_worktree_output(
};
// Show success message (includes emoji and color)
- super::success(format_remove_worktree_message(
+ super::print(success_message(format_remove_worktree_message(
main_path,
changed_directory,
branch_name,
@@ -625,7 +634,7 @@ fn handle_removed_worktree_output(
force_delete,
integration_reason,
target_branch,
- ))?;
+ )))?;
super::flush()?;
Ok(())
diff --git a/src/output/interactive.rs b/src/output/interactive.rs
index 4a790c8b8..1ae389a52 100644
--- a/src/output/interactive.rs
+++ b/src/output/interactive.rs
@@ -45,7 +45,8 @@ impl OutputHandler for InteractiveOutput {
fn shell_integration_hint(&mut self, message: String) -> io::Result<()> {
// Shell integration hints work the same as regular hints in interactive mode
- self.hint(message)
+ use worktrunk::styling::hint_message;
+ self.write_message_line(&hint_message(&message))
}
fn change_directory(&mut self, path: &Path) -> io::Result<()> {
diff --git a/src/output/mod.rs b/src/output/mod.rs
index 17a80cffc..b5857ba80 100644
--- a/src/output/mod.rs
+++ b/src/output/mod.rs
@@ -33,6 +33,8 @@
//! ## Usage Pattern
//!
//! ```rust,ignore
+//! use worktrunk::styling::{success_message, error_message, hint_message};
+//!
//! // 1. Initialize once in main()
//! let mode = if internal {
//! OutputMode::Directive
@@ -42,7 +44,7 @@
//! output::initialize(mode);
//!
//! // 2. Use anywhere in the codebase
-//! output::success("Operation complete");
+//! output::print(success_message("Operation complete"));
//! output::change_directory(&path);
//! output::execute("git pull");
//! output::flush();
@@ -63,9 +65,8 @@ mod traits;
// Re-export the public API
pub use global::{
- OutputMode, blank, change_directory, data, error, execute, flush, flush_for_stderr_prompt,
- gutter, hint, info, initialize, print, progress, shell_integration_hint, success, table,
- terminate_output, warning,
+ OutputMode, blank, change_directory, data, execute, flush, flush_for_stderr_prompt, gutter,
+ initialize, print, shell_integration_hint, table, terminate_output,
};
// Re-export output handlers
pub use handlers::{
diff --git a/src/output/traits.rs b/src/output/traits.rs
index e23fa77da..5952cd21d 100644
--- a/src/output/traits.rs
+++ b/src/output/traits.rs
@@ -4,65 +4,50 @@
//! The fundamental operation is `write_message_line` - implementations control where
//! messages go (stdout for interactive, stderr for directive).
//!
-//! # Semantic Colors
+//! # Message Formatting
//!
-//! Output functions automatically wrap content in semantic colors:
-//! - success β†’ green
-//! - progress β†’ cyan
-//! - hint β†’ dimmed
-//! - warning β†’ yellow
-//! - error β†’ red
-//! - info β†’ no color (neutral status)
+//! For semantic messages (errors, hints, warnings, etc.), use the message formatting
+//! functions from `worktrunk::styling` with `output::print()`:
//!
-//! Callers provide content with optional inner styling (like `<bold>`) using `cformat!`.
-//! The trait adds the outer semantic color, so callers don't repeat `<green>...</>` etc.
+//! ```ignore
+//! use worktrunk::styling::{error_message, success_message, hint_message};
+//! output::print(error_message("Operation failed"))?;
+//! output::print(success_message("Operation complete"))?;
+//! output::print(hint_message("Try --force"))?;
+//! ```
+//!
+//! This decouples message formatting from the output system, allowing the same
+//! formatting functions to be used both for output and in Display impls.
-use color_print::cformat;
use std::io::{self, Write};
use std::path::Path;
-use worktrunk::styling::{
- ERROR_EMOJI, HINT_EMOJI, INFO_EMOJI, PROGRESS_EMOJI, SUCCESS_EMOJI, WARNING_EMOJI,
-};
/// Core output handler trait
///
/// Implementations provide their message stream via `write_message_line`
/// and override only the methods that differ between modes.
+///
+/// # Message Formatting
+///
+/// For semantic messages (errors, hints, etc.), use the message formatting functions
+/// from `worktrunk::styling` combined with `print()`:
+///
+/// ```ignore
+/// use worktrunk::styling::{error_message, hint_message};
+/// output::print(error_message("Something went wrong"))?;
+/// output::print(hint_message("Try --force"))?;
+/// ```
pub trait OutputHandler {
/// Write a single logical message line to the primary user stream
fn write_message_line(&mut self, line: &str) -> io::Result<()>;
- /// Emit a success message (automatically wrapped in green)
- fn success(&mut self, message: String) -> io::Result<()> {
- self.write_message_line(&cformat!("{SUCCESS_EMOJI} <green>{message}</>"))
- }
-
- /// Emit a progress message (automatically wrapped in cyan)
- fn progress(&mut self, message: String) -> io::Result<()> {
- self.write_message_line(&cformat!("{PROGRESS_EMOJI} <cyan>{message}</>"))
- }
-
- /// Emit a hint message (automatically wrapped in dim styling)
- fn hint(&mut self, message: String) -> io::Result<()> {
- self.write_message_line(&cformat!("{HINT_EMOJI} <dim>{message}</>"))
- }
-
- /// Emit an info message (no color - neutral status)
- fn info(&mut self, message: String) -> io::Result<()> {
- self.write_message_line(&cformat!("{INFO_EMOJI} {message}"))
- }
-
- /// Emit a warning message (automatically wrapped in yellow)
- fn warning(&mut self, message: String) -> io::Result<()> {
- self.write_message_line(&cformat!("{WARNING_EMOJI} <yellow>{message}</>"))
- }
-
- /// Emit an error message (automatically wrapped in red)
- fn error(&mut self, message: String) -> io::Result<()> {
- self.write_message_line(&cformat!("{ERROR_EMOJI} <red>{message}</>"))
- }
-
/// Print a message (written as-is)
+ ///
+ /// Use with message formatting functions for semantic output:
+ /// ```ignore
+ /// output::print(error_message("Failed"))?;
+ /// output::print(success_message("Done"))?;
+ /// ```
fn print(&mut self, message: String) -> io::Result<()> {
self.write_message_line(&message)
}
diff --git a/src/styling/constants.rs b/src/styling/constants.rs
index 97e8e9024..f80216f16 100644
--- a/src/styling/constants.rs
+++ b/src/styling/constants.rs
@@ -77,3 +77,48 @@ pub const INFO_EMOJI: &str = "βšͺ";
/// Prompt emoji - use for questions requiring user input
/// `eprint!("{PROMPT_EMOJI} Proceed? [y/N] ")`
pub const PROMPT_EMOJI: &str = "❓";
+
+// ============================================================================
+// Message Formatting Functions
+// ============================================================================
+//
+// These functions provide the canonical formatting for each message type.
+// Used by both the output system (output::error, etc.) and Display impls
+// (GitError, WorktrunkError) to ensure consistent styling.
+
+use color_print::cformat;
+
+/// Format an error message with emoji and red styling
+///
+/// Content can include inner styling like `<bold>`:
+/// ```ignore
+/// error_message(cformat!("Branch <bold>{name}</> not found"))
+/// ```
+pub fn error_message(content: impl AsRef<str>) -> String {
+ cformat!("{ERROR_EMOJI} <red>{}</>", content.as_ref())
+}
+
+/// Format a hint message with emoji and dim styling
+pub fn hint_message(content: impl AsRef<str>) -> String {
+ cformat!("{HINT_EMOJI} <dim>{}</>", content.as_ref())
+}
+
+/// Format a warning message with emoji and yellow styling
+pub fn warning_message(content: impl AsRef<str>) -> String {
+ cformat!("{WARNING_EMOJI} <yellow>{}</>", content.as_ref())
+}
+
+/// Format a success message with emoji and green styling
+pub fn success_message(content: impl AsRef<str>) -> String {
+ cformat!("{SUCCESS_EMOJI} <green>{}</>", content.as_ref())
+}
+
+/// Format a progress message with emoji and cyan styling
+pub fn progress_message(content: impl AsRef<str>) -> String {
+ cformat!("{PROGRESS_EMOJI} <cyan>{}</>", content.as_ref())
+}
+
+/// Format an info message with emoji (no color - neutral status)
+pub fn info_message(content: impl AsRef<str>) -> String {
+ cformat!("{INFO_EMOJI} {}", content.as_ref())
+}
diff --git a/tests/snapshots/git_error_display__detached_head.snap b/tests/snapshots/git_error_display__detached_head.snap
index 695466caf..8afaf2147 100644
--- a/tests/snapshots/git_error_display__detached_head.snap
+++ b/tests/snapshots/git_error_display__detached_head.snap
@@ -4,4 +4,4 @@ expression: err.to_string()
---
❌ Cannot merge: not on a branch (detached HEAD)
-πŸ’‘ Switch to a branch first with git switch <branch>
+πŸ’‘ Switch to a branch first with git switch <branch>
diff --git a/tests/snapshots/git_error_display__detached_head_no_action.snap b/tests/snapshots/git_error_display__detached_head_no_action.snap
index 8d870d1f0..70cf6083a 100644
--- a/tests/snapshots/git_error_display__detached_head_no_action.snap
+++ b/tests/snapshots/git_error_display__detached_head_no_action.snap
@@ -4,4 +4,4 @@ expression: err.to_string()
---
❌ Not on a branch (detached HEAD)
-πŸ’‘ Switch to a branch first with git switch <branch>
+πŸ’‘ Switch to a branch first with git switch <branch>
diff --git a/tests/snapshots/git_error_display__no_worktree_found.snap b/tests/snapshots/git_error_display__no_worktree_found.snap
index 5645c71d6..aae61276b 100644
--- a/tests/snapshots/git_error_display__no_worktree_found.snap
+++ b/tests/snapshots/git_error_display__no_worktree_found.snap
@@ -2,4 +2,4 @@
source: tests/git_error_display.rs
expression: err.to_string()
---
-❌ No worktree found for branch nonexistent
+❌ No worktree found for branch nonexistent
diff --git a/tests/snapshots/git_error_display__worktree_creation_failed.snap b/tests/snapshots/git_error_display__worktree_creation_failed.snap
index 795c44a4e..1d93165c2 100644
--- a/tests/snapshots/git_error_display__worktree_creation_failed.snap
+++ b/tests/snapshots/git_error_display__worktree_creation_failed.snap
@@ -2,5 +2,5 @@
source: tests/git_error_display.rs
expression: err.to_string()
---
-❌ Failed to create worktree for feature-y from base main
+❌ Failed to create worktree for feature-y from base main
  fatal: '/tmp/repo.feature-y' already exists
diff --git a/tests/snapshots/git_error_display__worktree_missing.snap b/tests/snapshots/git_error_display__worktree_missing.snap
index 8e28f2a49..731368472 100644
--- a/tests/snapshots/git_error_display__worktree_missing.snap
+++ b/tests/snapshots/git_error_display__worktree_missing.snap
@@ -2,6 +2,6 @@
source: tests/git_error_display.rs
expression: err.to_string()
---
-❌ Worktree directory missing for stale-branch
+❌ Worktree directory missing for stale-branch
πŸ’‘ Run git worktree prune to clean up
diff --git a/tests/snapshots/git_error_display__worktree_path_exists.snap b/tests/snapshots/git_error_display__worktree_path_exists.snap
index 9c13a9f12..15db75629 100644
--- a/tests/snapshots/git_error_display__worktree_path_exists.snap
+++ b/tests/snapshots/git_error_display__worktree_path_exists.snap
@@ -2,6 +2,6 @@
source: tests/git_error_display.rs
expression: err.to_string()
---
-❌ Directory already exists: /tmp/repo.feature
+❌ Directory already exists: /tmp/repo.feature
πŸ’‘ Remove the directory or use a different branch name
diff --git a/tests/snapshots/git_error_display__worktree_path_mismatch.snap b/tests/snapshots/git_error_display__worktree_path_mismatch.snap
index 0cb04476d..bcb8df561 100644
--- a/tests/snapshots/git_error_display__worktree_path_mismatch.snap
+++ b/tests/snapshots/git_error_display__worktree_path_mismatch.snap
@@ -2,6 +2,6 @@
source: tests/git_error_display.rs
expression: err.to_string()
---
-❌ Ambiguous: /tmp/repo.feature has a worktree on a different branch, but branch feature exists at /tmp/repo.other
+❌ Ambiguous: /tmp/repo.feature has a worktree on a different branch, but branch feature exists at /tmp/repo.other
πŸ’‘ Use wt list to see worktree-branch mappings
diff --git a/tests/snapshots/git_error_display__worktree_removal_failed.snap b/tests/snapshots/git_error_display__worktree_removal_failed.snap
index e533bbf10..0b9679252 100644
--- a/tests/snapshots/git_error_display__worktree_removal_failed.snap
+++ b/tests/snapshots/git_error_display__worktree_removal_failed.snap
@@ -2,6 +2,6 @@
source: tests/git_error_display.rs
expression: err.to_string()
---
-❌ Failed to remove worktree for feature-x at /tmp/repo.feature-x
+❌ Failed to remove worktree for feature-x at /tmp/repo.feature-x
  fatal: worktree is dirty
  error: could not remove worktree
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 a6a747626..7008267ba 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
@@ -25,4 +25,4 @@ exit_code: 1
----- stderr -----
❌ Cannot merge: not on a branch (detached HEAD)
-πŸ’‘ Switch to a branch first with git switch <branch>
+πŸ’‘ Switch to a branch first with git switch <branch>
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snap b/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snap
index 81fee084f..40cf0d236 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snap
@@ -23,4 +23,4 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ No worktree found for branch nonexistent
+❌ No worktree found for branch nonexistent
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 fb547a9a3..85e6e29ae 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
@@ -24,6 +24,6 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Worktree directory missing for missing-wt
+❌ Worktree directory missing for missing-wt
πŸ’‘ Run git worktree prune to clean up
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied.snap b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied.snap
index e6360dc11..4601c6d2d 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied.snap
@@ -25,6 +25,6 @@ exit_code: 1
----- stdout -----
----- stderr -----
-❌ Directory already exists: [REPO]/../repo.occupied-branch
+❌ Directory already exists: [REPO]/../repo.occupied-branch
πŸ’‘ Remove the directory or use a different branch name