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.rsindex 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::Resulwriteln!(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 existsif !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.rsindex 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.rsindex 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 madediff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rsindex 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"[107m [0m [1m[36m[post-start][107m [0m server = [32m"npm run dev"- [2m⚪ Skipped bash; ~/.bashrc not found[22m- [2m⚪ Skipped zsh; ~/.zshrc not found[22m- [2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+ ⚪ [2mSkipped bash; ~/.bashrc not found[22m+ ⚪ [2mSkipped zsh; ~/.zshrc not found[22m+ ⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22m"#);});}@@ -105,9 +105,9 @@ fn test_config_show_no_project_config() {[36mPROJECT CONFIG[39m [REPO]/.config/wt.toml💡 [2mNot found[22m- [2m⚪ Skipped bash; ~/.bashrc not found[22m- [2m⚪ Skipped zsh; ~/.zshrc not found[22m- [2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+ ⚪ [2mSkipped bash; ~/.bashrc not found[22m+ ⚪ [2mSkipped zsh; ~/.zshrc not found[22m+ ⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22m"#);});}@@ -145,9 +145,9 @@ fn test_config_show_outside_git_repo() {[36m[2mPROJECT CONFIG[22m Not in a git repository[39m- [2m⚪ Skipped bash; ~/.bashrc not found[22m- [2m⚪ Skipped zsh; ~/.zshrc not found[22m- [2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+ ⚪ [2mSkipped bash; ~/.bashrc not found[22m+ ⚪ [2mSkipped zsh; ~/.zshrc not found[22m+ ⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22m"#);});}@@ -306,9 +306,9 @@ fn test_config_show_warns_unknown_project_keys() {[107m [0m [1m[36m[post-merge-command][107m [0m deploy = [32m"task deploy"- [2m⚪ Skipped bash; ~/.bashrc not found[22m- [2m⚪ Skipped zsh; ~/.zshrc not found[22m- [2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+ ⚪ [2mSkipped bash; ~/.bashrc not found[22m+ ⚪ [2mSkipped zsh; ~/.zshrc not found[22m+ ⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22m"#);});}@@ -351,9 +351,9 @@ fn test_config_show_warns_unknown_user_keys() {[36mPROJECT CONFIG[39m [REPO]/.config/wt.toml💡 [2mNot found[22m- [2m⚪ Skipped bash; ~/.bashrc not found[22m- [2m⚪ Skipped zsh; ~/.zshrc not found[22m- [2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+ ⚪ [2mSkipped bash; ~/.bashrc not found[22m+ ⚪ [2mSkipped zsh; ~/.zshrc not found[22m+ ⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22m"#);});}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.snapindex 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/.configCLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -38,9 +38,9 @@ exit_code: 0[36mPROJECT CONFIG[39m [REPO]/.config/wt.toml💡 [2mNot found[22m-[2m⚪ Skipped bash; ~/.bashrc not found[22m-[2m⚪ Skipped zsh; ~/.zshrc not found[22m-[2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+⚪ [2mSkipped bash; ~/.bashrc not found[22m+⚪ [2mSkipped zsh; ~/.zshrc not found[22m+⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22m⚪ 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.snapindex 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/.configCLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -34,9 +34,9 @@ exit_code: 0[36mPROJECT CONFIG[39m [REPO]/.config/wt.toml💡 [2mNot found[22m-[2m⚪ Skipped bash; ~/.bashrc not found[22m-[2m⚪ Skipped zsh; ~/.zshrc not found[22m-[2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+⚪ [2mSkipped bash; ~/.bashrc not found[22m+⚪ [2mSkipped zsh; ~/.zshrc not found[22m+⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22m⚪ 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.snapindex 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- showenv:+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpe62ExY/.configCLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -17,6 +18,7 @@ info:LANG: CLC_ALL: CSOURCE_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💡 [2mNot configured shell extension & completions for bash @ ~/.bashrc[22m⚪ Already configured shell extension & completions for [1mzsh[22m @ ~/.zshrc-[2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22m-💡 [2mRun [90mwt config shell install[39m to enable shell integration[22m+💡 [2m[90mwt config shell install[39m enables shell integration[22mdiff --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.snapindex 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- showenv:+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp0MPkhE/.configCLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -17,6 +18,7 @@ info:LANG: CLC_ALL: CSOURCE_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💡 [2mNot found[22m⚪ Already configured shell extension & completions for [1mzsh[22m @ ~/.zshrc-[2m⚪ Skipped bash; ~/.bashrc not found[22m-[2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+⚪ [2mSkipped bash; ~/.bashrc not found[22m+⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22mdiff --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.snapindex 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- showenv:+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpK02YUP/.configCLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -17,6 +18,7 @@ info:LANG: CLC_ALL: CSOURCE_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 [1mzsh[22m @ ~/.zshrc🟡 [33mCompletions won't work; add to ~/.zshrc before the wt line:[39m[107m [0m autoload -Uz compinit && compinit-[2m⚪ Skipped bash; ~/.bashrc not found[22m-[2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+⚪ [2mSkipped bash; ~/.bashrc not found[22m+⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22mdiff --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.snapindex 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- showenv:- APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpP7IhTH/.config+ APPDATA: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp77cGMU/.configCLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -34,6 +34,6 @@ exit_code: 0[36mPROJECT CONFIG[39m [REPO]/.config/wt.toml💡 [2mNot found[22m-[2m⚪ Skipped bash; ~/.bashrc not found[22m-[2m⚪ Skipped zsh; ~/.zshrc not found[22m-[2m⚪ Skipped fish; ~/.config/fish/conf.d not found[22m+⚪ [2mSkipped bash; ~/.bashrc not found[22m+⚪ [2mSkipped zsh; ~/.zshrc not found[22m+⚪ [2mSkipped fish; ~/.config/fish/conf.d not found[22mdiff --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.snapindex 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 -----🔄 [36m[36mRemoving [1mfeature-unmerged[22m worktree in background; retaining unmerged branch[39m[39m-💡 [2mUse [22mwt remove -D[2m to delete unmerged branches[22m+💡 [2m[90mwt remove -D[39m deletes unmerged branches[22mdiff --git a/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snap b/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snapindex 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 -----🟡 [33mNo worktree found for branch [1mfeature-unmerged[22m[39m⚪ Branch [1mfeature-unmerged[22m retained; has unmerged changes-💡 [2mUse [22mwt remove -D[2m to delete unmerged branches[22m+💡 [2m[90mwt remove -D[39m deletes unmerged branches[22m