Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Silence alias banner when there is no pipeline summary to show (#2339)
Maximilian Roosc7e7db960606
diff --git a/src/commands/alias.rs b/src/commands/alias.rsindex 4673c4d34..4c5fb02d6 100644--- a/src/commands/alias.rs+++ b/src/commands/alias.rs@@ -289,26 +289,28 @@ fn unknown_step_command_error(name: &str, alias_names: &[String]) -> anyhow::Errcrate::enhance_clap_error(build_invalid_subcommand_error(step_cmd, name, suggestions))}-/// Format the "Running alias …" announcement.+/// Format the informative "Running alias …" announcement, or `None` when+/// there is nothing beyond the alias name to announce.///-/// For pipelines or concurrent groups with named commands, includes a summary-/// of the structure (e.g., `Running alias deploy: install; build, lint`).-/// When all commands are unnamed, falls back to the bare form-/// (`Running alias deploy`) — aliases have no natural fallback label for-/// unnamed steps the way hooks use `user`/`project`.+/// Returns `Some(…)` only when the alias has at least one named step, so the+/// banner can carry a pipeline summary (e.g., `Running alias deploy: install;+/// build, lint`). Single unnamed aliases (`ls = "wt list"`) and all-anonymous+/// pipelines (`foo = ["a", "b"]`) return `None` — the banner would only echo+/// the name the user just typed. Callers that still want a confirmation line+/// (e.g. under `-v`) emit a bare `Running alias <name>` themselves.////// Sibling of `format_command_label` in `commands/mod.rs`, which builds the/// non-pipeline `Running {type} {name}` form for hooks. Both apply bold/// styling to the alias/command name — keep them in sync if styling evolves.-fn format_alias_announcement(name: &str, cmd_config: &CommandConfig) -> String {+fn format_alias_announcement(name: &str, cmd_config: &CommandConfig) -> Option<String> {let step_names = step_names_from_config(cmd_config);let summary =format_pipeline_summary_from_names(&step_names, |n| cformat!("<bold>{n}</>"), |_| None);if summary.is_empty() {- cformat!("Running alias <bold>{name}</>")+ None} else {- cformat!("Running alias <bold>{name}</>: {summary}")+ Some(cformat!("Running alias <bold>{name}</>: {summary}"))}}@@ -521,10 +523,14 @@ fn run_alias(eprintln!("{}", format_with_gutter(&vars, None));}- eprintln!(- "{}",- progress_message(format_alias_announcement(&opts.name, cmd_config))- );+ if let Some(msg) = format_alias_announcement(&opts.name, cmd_config) {+ eprintln!("{}", progress_message(msg));+ } else if verbosity() >= 1 {+ eprintln!(+ "{}",+ progress_message(cformat!("Running alias <bold>{}</>", opts.name))+ );+ }// CD passed through, EXEC scrubbed (see `output::global` for rationale).let directives = DirectivePassthrough::inherit_from_env();@@ -847,17 +853,16 @@ mod tests {#[test]fn test_format_alias_announcement_single_unnamed() {+ // Single unnamed alias — banner would only echo the name, so suppress.let cfg = cfg_from_toml(r#"cmd = "echo hi""#);- let msg = format_alias_announcement("deploy", &cfg);- insta::assert_snapshot!(msg.ansi_strip(), @"Running alias deploy");+ assert!(format_alias_announcement("deploy", &cfg).is_none());}#[test]fn test_format_alias_announcement_pipeline_all_unnamed() {- // Pipeline of unnamed strings → no summary suffix.+ // Pipeline of unnamed strings — still no summary content to show.let cfg = cfg_from_toml(r#"cmd = ["echo a", "echo b"]"#);- let msg = format_alias_announcement("deploy", &cfg);- insta::assert_snapshot!(msg.ansi_strip(), @"Running alias deploy");+ assert!(format_alias_announcement("deploy", &cfg).is_none());}#[test]@@ -870,7 +875,7 @@ build = "cargo build"test = "cargo test""#,);- let msg = format_alias_announcement("check", &cfg);+ let msg = format_alias_announcement("check", &cfg).expect("summary expected");insta::assert_snapshot!(msg.ansi_strip(), @"Running alias check: build, test");}@@ -885,7 +890,7 @@ cmd = []"#,);- let msg = format_alias_announcement("deploy", &cfg);+ let msg = format_alias_announcement("deploy", &cfg).expect("summary expected");insta::assert_snapshot!(msg.ansi_strip(), @"Running alias deploy: install; build, lint");}@@ -901,7 +906,7 @@ cmd = []"#,);- let msg = format_alias_announcement("ci", &cfg);+ let msg = format_alias_announcement("ci", &cfg).expect("summary expected");insta::assert_snapshot!(msg.ansi_strip(), @"Running alias ci: build, test");}diff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_append_executes_both.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_append_executes_both.snapindex 043801c92..ffe8d4691 100644--- a/tests/snapshots/integration__integration_tests__step_alias__alias_append_executes_both.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__alias_append_executes_both.snap@@ -3,9 +3,9 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- step- greet- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -45,6 +45,5 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mgreet[22m[39m[0mUSER[0mPROJECTdiff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_already_approved.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_already_approved.snapindex b284373b1..a5c1350c7 100644--- a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_already_approved.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_already_approved.snap@@ -44,5 +44,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mdeploy[22m[39m[0mdeploying featurediff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_user_and_project_both_need_approval.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_user_and_project_both_need_approval.snapindex ff606d25a..323eac9cc 100644--- a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_user_and_project_both_need_approval.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_user_and_project_both_need_approval.snap@@ -3,9 +3,9 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- step- deploy- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -45,6 +45,5 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mdeploy[22m[39m[0muser deploy[0mproject deploydiff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_user_config_skips.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_user_config_skips.snapindex fcb703123..66c551968 100644--- a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_user_config_skips.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_user_config_skips.snap@@ -44,5 +44,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mdeploy[22m[39m[0mdeploying from user configdiff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_yes_first_run.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_yes_first_run.snapindex b4fb27c8c..d3382e3e1 100644--- a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_yes_first_run.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_yes_first_run.snap@@ -3,9 +3,9 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- step- deploy- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -45,5 +45,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mdeploy[22m[39m[0mdeployingdiff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_args_sequence_access.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_args_sequence_access.snapindex bfbe6f9e7..1f6ba9dee 100644--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_args_sequence_access.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_args_sequence_access.snap@@ -3,10 +3,10 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- show- alpha- beta gamma- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -46,7 +46,6 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mshow[22m[39m[0mfirst=alphacount=2each= alpha beta gammadiff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_double_dash_escape.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_double_dash_escape.snapindex 772804f95..28a3dcde8 100644--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_double_dash_escape.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_double_dash_escape.snap@@ -3,8 +3,8 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- run- - "--yes"- "--"- "--env=staging"- literal@@ -47,5 +47,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mrun[22m[39m[0mgot --env=staging literaldiff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_empty_args_renders_empty.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_empty_args_renders_empty.snapindex 1e8ba6a8d..6ba320e4d 100644--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_empty_args_renders_empty.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_empty_args_renders_empty.snap@@ -3,8 +3,8 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- run- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -44,5 +44,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mrun[22m[39m[0m[]diff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_exit_code.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_exit_code.snapindex 28b73dca7..2d6f2cd39 100644--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_exit_code.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_exit_code.snap@@ -3,9 +3,9 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- step- fail- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -45,4 +45,3 @@ exit_code: 42----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mfail[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_forwards_positional_args.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_forwards_positional_args.snapindex 9644b932e..1b6bf9b97 100644--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_forwards_positional_args.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_forwards_positional_args.snap@@ -3,11 +3,11 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- run- one- two three- four- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -47,5 +47,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mrun[22m[39m[0mgot one two three fourdiff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_from_project_config.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_from_project_config.snapindex 7f9a74752..07acb0bcc 100644--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_from_project_config.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_from_project_config.snap@@ -3,9 +3,9 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- step- hello- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -45,5 +45,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mhello[22m[39m[0mHello from featurediff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_from_user_config.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_from_user_config.snapindex 184669662..0db6e1afd 100644--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_from_user_config.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_from_user_config.snap@@ -44,5 +44,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mgreet[22m[39m[0mGreetings from featurediff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_unreferenced_key_forwards_to_args.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_unreferenced_key_forwards_to_args.snapindex 6c8a0e56e..1958a0913 100644--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_unreferenced_key_forwards_to_args.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_unreferenced_key_forwards_to_args.snap@@ -3,10 +3,10 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- run- "--env=staging"- foo- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -46,5 +46,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mrun[22m[39m[0mgot --env=staging foodiff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_user_var_overshadows_builtin.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_user_var_overshadows_builtin.snapindex a121b6a1d..2ca17594b 100644--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_user_var_overshadows_builtin.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_user_var_overshadows_builtin.snap@@ -3,9 +3,9 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- show- "--branch=override"- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -45,5 +45,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mshow[22m[39m[0mbranch=overridediff --git a/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_dispatch.snap b/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_dispatch.snapindex 33c4c7318..34204883b 100644--- a/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_dispatch.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_dispatch.snap@@ -3,8 +3,8 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- hello- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -44,5 +44,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mhello[22m[39m[0mHello from featurediff --git a/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_with_step_builtin_name.snap b/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_with_step_builtin_name.snapindex 0b87a85e5..53f4f2e58 100644--- a/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_with_step_builtin_name.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_with_step_builtin_name.snap@@ -3,8 +3,8 @@ source: tests/integration_tests/step_alias.rsinfo:program: wtargs:+ - "-y"- commit- - "--yes"env:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"@@ -44,5 +44,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning alias [1mcommit[22m[39m[0mcustom-commit