Skip to content

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.rs
index 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::Err
crate::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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- step
- greet
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -45,6 +45,5 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias greet
USER
PROJECT
diff --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.snap
index 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 -----
-◎ Running alias deploy
deploying feature
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- step
- deploy
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -45,6 +45,5 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias deploy
user deploy
project deploy
diff --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.snap
index 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 -----
-◎ Running alias deploy
deploying from user config
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- step
- deploy
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -45,5 +45,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias deploy
deploying
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- show
- alpha
- beta gamma
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -46,7 +46,6 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias show
first=alpha
count=2
each= alpha beta gamma
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- run
- - "--yes"
- "--"
- "--env=staging"
- literal
@@ -47,5 +47,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias run
got --env=staging literal
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- run
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -44,5 +44,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias run
[]
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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- step
- fail
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -45,4 +45,3 @@ exit_code: 42
----- stdout -----
----- stderr -----
-◎ Running alias fail
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- run
- one
- two three
- four
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -47,5 +47,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias run
got one two three four
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- step
- hello
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -45,5 +45,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias hello
Hello from feature
diff --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.snap
index 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 -----
-◎ Running alias greet
Greetings from feature
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- run
- "--env=staging"
- foo
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -46,5 +46,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias run
got --env=staging foo
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- show
- "--branch=override"
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -45,5 +45,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias show
branch=override
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- hello
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -44,5 +44,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias hello
Hello from feature
diff --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.snap
index 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.rs
info:
program: wt
args:
+ - "-y"
- commit
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -44,5 +44,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running alias commit
custom-commit