Skip to content

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

Refactor styling functions to use message helpers

Maximilian Roosfe42584c6d9c
diff --git a/src/commands/config.rs b/src/commands/config.rs
index 84c553947..1408cfbea 100644
--- a/src/commands/config.rs
+++ b/src/commands/config.rs
@@ -9,8 +9,8 @@ use worktrunk::git::Repository;
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,
+ error_message, format_toml, format_with_gutter, hint_message, info_message, progress_message,
+ success_message, warning_message,
};
use super::configure_shell::{ConfigAction, scan_shell_configs};
@@ -187,7 +187,7 @@ fn run_doctor_checks() -> anyhow::Result<()> {
output::gutter(format_with_gutter(&message, "", None))?;
}
Err(e) => {
- output::print(cformat!("{ERROR_EMOJI} <red>Commit generation failed</>"))?;
+ output::print(error_message("Commit generation failed"))?;
output::gutter(format_with_gutter(&e.to_string(), "", None))?;
output::blank()?;
output::print(hint_message(
@@ -216,9 +216,9 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {
writeln!(
out,
"{}",
- cformat!(
- "{HINT_EMOJI} <dim>Not found (using defaults); run <bright-black>wt config create</> to create</>"
- )
+ hint_message(cformat!(
+ "Not found (using defaults); <bright-black>wt config create</> creates one"
+ ))
)?;
writeln!(out)?;
let default_config =
@@ -231,11 +231,7 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {
let contents = std::fs::read_to_string(&config_path).context("Failed to read config file")?;
if contents.trim().is_empty() {
- writeln!(
- out,
- "{}",
- cformat!("{HINT_EMOJI} <dim>Empty file (using defaults)</>")
- )?;
+ writeln!(out, "{}", hint_message("Empty file (using defaults)"))?;
return Ok(());
}
@@ -254,7 +250,7 @@ fn warn_unknown_keys(out: &mut String, unknown_keys: &[String]) -> anyhow::Resul
writeln!(
out,
"{}",
- cformat!("{WARNING_EMOJI} <yellow>Unknown key <bold>{key}</> will be ignored</>")
+ warning_message(cformat!("Unknown key <bold>{key}</> will be ignored"))
)?;
}
Ok(())
@@ -287,7 +283,7 @@ fn render_project_config(out: &mut String) -> anyhow::Result<()> {
// Check if file exists
if !config_path.exists() {
- writeln!(out, "{}", cformat!("{HINT_EMOJI} <dim>Not found</>"))?;
+ writeln!(out, "{}", hint_message("Not found"))?;
return Ok(());
}
@@ -295,7 +291,7 @@ fn render_project_config(out: &mut String) -> anyhow::Result<()> {
let contents = std::fs::read_to_string(&config_path).context("Failed to read config file")?;
if contents.trim().is_empty() {
- writeln!(out, "{}", cformat!("{HINT_EMOJI} <dim>Empty file</>"))?;
+ writeln!(out, "{}", hint_message("Empty file"))?;
return Ok(());
}
@@ -316,7 +312,7 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {
writeln!(
out,
"{}",
- cformat!("{HINT_EMOJI} <dim>Could not determine shell status: {e}</>")
+ hint_message(format!("Could not determine shell status: {e}"))
)?;
return Ok(());
}
@@ -342,9 +338,9 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {
writeln!(
out,
"{}",
- cformat!(
- "{INFO_EMOJI} Already configured {what} for <bold>{shell}</> @ {path}"
- )
+ info_message(cformat!(
+ "Already configured {what} for <bold>{shell}</> @ {path}"
+ ))
)?;
// Check if zsh has compinit enabled (required for completions)
@@ -352,8 +348,8 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {
writeln!(
out,
"{}",
- cformat!(
- "{WARNING_EMOJI} <yellow>Completions won't work; add to ~/.zshrc before the wt line:</>"
+ warning_message(
+ "Completions won't work; add to ~/.zshrc before the wt line:"
)
)?;
write!(
@@ -372,18 +368,18 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {
writeln!(
out,
"{}",
- cformat!(
- "{INFO_EMOJI} Already configured completions for <bold>{shell}</> @ {completion_display}"
- )
+ info_message(cformat!(
+ "Already configured completions for <bold>{shell}</> @ {completion_display}"
+ ))
)?;
} else {
any_not_configured = true;
writeln!(
out,
"{}",
- cformat!(
- "{HINT_EMOJI} <dim>Not configured completions for {shell} @ {completion_display}</>"
- )
+ hint_message(format!(
+ "Not configured completions for {shell} @ {completion_display}"
+ ))
)?;
}
}
@@ -393,7 +389,7 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {
writeln!(
out,
"{}",
- cformat!("{HINT_EMOJI} <dim>Not configured {what} for {shell} @ {path}</>")
+ hint_message(format!("Not configured {what} for {shell} @ {path}"))
)?;
}
_ => {} // Added/Created won't appear in dry_run mode
@@ -406,7 +402,7 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {
writeln!(
out,
"{}",
- cformat!("<dim>⚪ Skipped {shell}; {path} not found</>")
+ info_message(cformat!("<dim>Skipped {shell}; {path} not found</>"))
)?;
}
@@ -416,9 +412,9 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {
writeln!(
out,
"{}",
- cformat!(
- "{HINT_EMOJI} <dim>Run <bright-black>wt config shell install</> to enable shell integration</>"
- )
+ hint_message(cformat!(
+ "<bright-black>wt config shell install</> enables shell integration"
+ ))
)?;
}
diff --git a/src/commands/standalone.rs b/src/commands/standalone.rs
index ff5b1230e..50694e310 100644
--- a/src/commands/standalone.rs
+++ b/src/commands/standalone.rs
@@ -6,8 +6,8 @@ use worktrunk::config::{CommandConfig, ProjectConfig, WorktrunkConfig};
use worktrunk::git::Repository;
use worktrunk::path::format_path_for_display;
use worktrunk::styling::{
- HINT_EMOJI, INFO_EMOJI, PROMPT_EMOJI, format_bash_with_gutter, format_with_gutter,
- hint_message, info_message, progress_message, success_message,
+ INFO_EMOJI, PROMPT_EMOJI, format_bash_with_gutter, format_with_gutter, hint_message,
+ info_message, progress_message, success_message,
};
use super::command_executor::CommandContext;
@@ -695,11 +695,7 @@ fn render_user_hooks(
}
if !has_any {
- writeln!(
- out,
- "{}",
- cformat!("{HINT_EMOJI} <dim>(none configured)</>")
- )?;
+ writeln!(out, "{}", hint_message("(none configured)"))?;
}
Ok(())
@@ -728,7 +724,7 @@ fn render_project_hooks(
)?;
let Some(config) = project_config else {
- writeln!(out, "{}", cformat!("{HINT_EMOJI} <dim>(not found)</>"))?;
+ writeln!(out, "{}", hint_message("(not found)"))?;
return Ok(());
};
@@ -758,11 +754,7 @@ fn render_project_hooks(
}
if !has_any {
- writeln!(
- out,
- "{}",
- cformat!("{HINT_EMOJI} <dim>(none configured)</>")
- )?;
+ writeln!(out, "{}", hint_message("(none configured)"))?;
}
Ok(())
diff --git a/src/output/handlers.rs b/src/output/handlers.rs
index 781b2ed43..5caf98d20 100644
--- a/src/output/handlers.rs
+++ b/src/output/handlers.rs
@@ -14,8 +14,8 @@ use worktrunk::git::Repository;
use worktrunk::path::format_path_for_display;
use worktrunk::shell::Shell;
use worktrunk::styling::{
- HINT_EMOJI, error_message, format_with_gutter, info_message, progress_message, success_message,
- warning_message,
+ error_message, format_with_gutter, hint_message, info_message, progress_message,
+ success_message, warning_message,
};
/// Format a switch success message with a consistent location phrase
@@ -224,9 +224,9 @@ fn handle_branch_deletion_result(
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</>"
- ))?;
+ super::print(hint_message(cformat!(
+ "<bright-black>wt remove -D</> deletes unmerged branches"
+ )))?;
result
}
Err(e) => {
@@ -648,9 +648,9 @@ fn handle_removed_worktree_output(
// Show hint for unmerged branches (same as synchronous path)
if !no_delete_branch && !should_delete_branch {
- super::print(cformat!(
- "{HINT_EMOJI} <dim>Use </>wt remove -D<dim> to delete unmerged branches</>"
- ))?;
+ super::print(hint_message(cformat!(
+ "<bright-black>wt remove -D</> deletes unmerged branches"
+ )))?;
}
// Build command with the decision we already made
diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rs
index a97b5ec00..8d980b609 100644
--- a/tests/integration_tests/config_show.rs
+++ b/tests/integration_tests/config_show.rs
@@ -63,9 +63,9 @@ server = "npm run dev"
  [post-start]
  server = "npm run dev"
- ⚪ Skipped bash; ~/.bashrc not found
- ⚪ Skipped zsh; ~/.zshrc not found
- ⚪ Skipped fish; ~/.config/fish/conf.d not found
+ ⚪ Skipped bash; ~/.bashrc not found
+ ⚪ Skipped zsh; ~/.zshrc not found
+ ⚪ Skipped fish; ~/.config/fish/conf.d not found
"#);
});
}
@@ -105,9 +105,9 @@ fn test_config_show_no_project_config() {
PROJECT CONFIG [REPO]/.config/wt.toml
💡 Not found
- ⚪ Skipped bash; ~/.bashrc not found
- ⚪ Skipped zsh; ~/.zshrc not found
- ⚪ Skipped fish; ~/.config/fish/conf.d not found
+ ⚪ Skipped bash; ~/.bashrc not found
+ ⚪ Skipped zsh; ~/.zshrc not found
+ ⚪ Skipped fish; ~/.config/fish/conf.d not found
"#);
});
}
@@ -145,9 +145,9 @@ fn test_config_show_outside_git_repo() {
PROJECT CONFIG Not in a git repository
- ⚪ Skipped bash; ~/.bashrc not found
- ⚪ Skipped zsh; ~/.zshrc not found
- ⚪ Skipped fish; ~/.config/fish/conf.d not found
+ ⚪ Skipped bash; ~/.bashrc not found
+ ⚪ Skipped zsh; ~/.zshrc not found
+ ⚪ Skipped fish; ~/.config/fish/conf.d not found
"#);
});
}
@@ -306,9 +306,9 @@ fn test_config_show_warns_unknown_project_keys() {
  [post-merge-command]
  deploy = "task deploy"
- ⚪ Skipped bash; ~/.bashrc not found
- ⚪ Skipped zsh; ~/.zshrc not found
- ⚪ Skipped fish; ~/.config/fish/conf.d not found
+ ⚪ Skipped bash; ~/.bashrc not found
+ ⚪ Skipped zsh; ~/.zshrc not found
+ ⚪ Skipped fish; ~/.config/fish/conf.d not found
"#);
});
}
@@ -351,9 +351,9 @@ fn test_config_show_warns_unknown_user_keys() {
PROJECT CONFIG [REPO]/.config/wt.toml
💡 Not found
- ⚪ Skipped bash; ~/.bashrc not found
- ⚪ Skipped zsh; ~/.zshrc not found
- ⚪ Skipped fish; ~/.config/fish/conf.d not found
+ ⚪ Skipped bash; ~/.bashrc not found
+ ⚪ Skipped zsh; ~/.zshrc not found
+ ⚪ Skipped fish; ~/.config/fish/conf.d not found
"#);
});
}
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_doctor_command_not_found.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_doctor_command_not_found.snap
index 240d73ff7..3c8c69998 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_doctor_command_not_found.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_doctor_command_not_found.snap
@@ -7,7 +7,7 @@ info:
- show
- "--doctor"
env:
- APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpaIcCCZ/.config
+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpjj5ErM/.config
CLICOLOR_FORCE: "1"
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
@@ -38,9 +38,9 @@ exit_code: 0
PROJECT CONFIG [REPO]/.config/wt.toml
💡 Not found
-⚪ Skipped bash; ~/.bashrc not found
-⚪ Skipped zsh; ~/.zshrc not found
-⚪ Skipped fish; ~/.config/fish/conf.d not found
+⚪ Skipped bash; ~/.bashrc not found
+⚪ Skipped zsh; ~/.zshrc not found
+⚪ Skipped fish; ~/.config/fish/conf.d not found
⚪ Running diagnostic checks...
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_doctor_not_configured.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_doctor_not_configured.snap
index 9351f64c3..a12da38db 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_doctor_not_configured.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_doctor_not_configured.snap
@@ -7,7 +7,7 @@ info:
- show
- "--doctor"
env:
- APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpH4nLBV/.config
+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpiw5aui/.config
CLICOLOR_FORCE: "1"
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
@@ -34,9 +34,9 @@ exit_code: 0
PROJECT CONFIG [REPO]/.config/wt.toml
💡 Not found
-⚪ Skipped bash; ~/.bashrc not found
-⚪ Skipped zsh; ~/.zshrc not found
-⚪ Skipped fish; ~/.config/fish/conf.d not found
+⚪ Skipped bash; ~/.bashrc not found
+⚪ Skipped zsh; ~/.zshrc not found
+⚪ Skipped fish; ~/.config/fish/conf.d not found
⚪ Running diagnostic checks...
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap
index 19afdfbee..c20fd3d88 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap
@@ -6,6 +6,7 @@ info:
- config
- show
env:
+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpe62ExY/.config
CLICOLOR_FORCE: "1"
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
@@ -17,6 +18,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1735776000"
+ USERPROFILE: "[TEST_HOME]"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_COMPINIT_CONFIGURED: "1"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -34,6 +36,6 @@ exit_code: 0
💡 Not configured shell extension & completions for bash @ ~/.bashrc
⚪ Already configured shell extension & completions for zsh @ ~/.zshrc
-⚪ Skipped fish; ~/.config/fish/conf.d not found
+⚪ Skipped fish; ~/.config/fish/conf.d not found
-💡 Run wt config shell install to enable shell integration
+💡 wt config shell install enables shell integration
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap
index 54b5daab3..dc3c757ef 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap
@@ -6,6 +6,7 @@ info:
- config
- show
env:
+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp0MPkhE/.config
CLICOLOR_FORCE: "1"
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
@@ -17,6 +18,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1735776000"
+ USERPROFILE: "[TEST_HOME]"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_COMPINIT_CONFIGURED: "1"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -33,5 +35,5 @@ exit_code: 0
💡 Not found
⚪ Already configured shell extension & completions for zsh @ ~/.zshrc
-⚪ Skipped bash; ~/.bashrc not found
-⚪ Skipped fish; ~/.config/fish/conf.d not found
+⚪ Skipped bash; ~/.bashrc not found
+⚪ Skipped fish; ~/.config/fish/conf.d not found
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap
index 2ff3f39f4..9cfd2c6a3 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap
@@ -6,6 +6,7 @@ info:
- config
- show
env:
+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpK02YUP/.config
CLICOLOR_FORCE: "1"
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
@@ -17,6 +18,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1735776000"
+ USERPROFILE: "[TEST_HOME]"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_COMPINIT_MISSING: "1"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -35,5 +37,5 @@ exit_code: 0
⚪ Already configured shell extension & completions for zsh @ ~/.zshrc
🟡 Completions won't work; add to ~/.zshrc before the wt line:
  autoload -Uz compinit && compinit
-⚪ Skipped bash; ~/.bashrc not found
-⚪ Skipped fish; ~/.config/fish/conf.d not found
+⚪ Skipped bash; ~/.bashrc not found
+⚪ Skipped fish; ~/.config/fish/conf.d not found
diff --git a/tests/snapshots/integration__integration_tests__internal_flag__config_show_with_internal_flag.snap b/tests/snapshots/integration__integration_tests__internal_flag__config_show_with_internal_flag.snap
index 9d671fb5a..82278e3c9 100644
--- a/tests/snapshots/integration__integration_tests__internal_flag__config_show_with_internal_flag.snap
+++ b/tests/snapshots/integration__integration_tests__internal_flag__config_show_with_internal_flag.snap
@@ -7,7 +7,7 @@ info:
- config
- show
env:
- APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpP7IhTH/.config
+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp77cGMU/.config
CLICOLOR_FORCE: "1"
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
@@ -34,6 +34,6 @@ exit_code: 0
PROJECT CONFIG [REPO]/.config/wt.toml
💡 Not found
-⚪ Skipped bash; ~/.bashrc not found
-⚪ Skipped zsh; ~/.zshrc not found
-⚪ Skipped fish; ~/.config/fish/conf.d not found
+⚪ Skipped bash; ~/.bashrc not found
+⚪ Skipped zsh; ~/.zshrc not found
+⚪ Skipped fish; ~/.config/fish/conf.d not found
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_branch_not_fully_merged.snap b/tests/snapshots/integration__integration_tests__remove__remove_branch_not_fully_merged.snap
index d25d89ecf..5583dc291 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_branch_not_fully_merged.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_branch_not_fully_merged.snap
@@ -24,4 +24,4 @@ exit_code: 0
----- stderr -----
🔄 Removing feature-unmerged worktree in background; retaining unmerged branch
-💡 Use wt remove -D to delete unmerged branches
+💡 wt remove -D deletes unmerged branches
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snap b/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snap
index d1a71698f..ca2cae1a3 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snap
@@ -25,4 +25,4 @@ exit_code: 0
----- stderr -----
🟡 No worktree found for branch feature-unmerged
⚪ Branch feature-unmerged retained; has unmerged changes
-💡 Use wt remove -D to delete unmerged branches
+💡 wt remove -D deletes unmerged branches