Skip to content

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

feat(config): add wt config alias show and dry-run subcommands (#2291)

Maximilian Roosc7b94a7276bf
diff --git a/docs/content/config.md b/docs/content/config.md
index d7add3385..7463d4887 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -478,6 +478,7 @@ Usage: <b><span class=c>wt config</span></b> <span class=c>[OPTIONS]</span> <spa
<b><span class=c>show</span></b> Show configuration files &amp; locations
<b><span class=c>update</span></b> Update deprecated config settings
<b><span class=c>approvals</span></b> Manage command approvals
+ <b><span class=c>alias</span></b> Inspect and preview aliases
<b><span class=c>plugins</span></b> Plugin management
<b><span class=c>state</span></b> Manage internal data and cache
@@ -612,6 +613,50 @@ Usage: <b><span class=c>wt config approvals</span></b> <span class=c>[OPTIONS]</
Skip approval prompts
{% end %}
+## wt config alias
+
+Inspect and preview aliases.
+
+Aliases are command templates configured in user (`~/.config/worktrunk/config.toml`) or project (`.config/wt.toml`) config and run as `wt <name>`. See [Aliases](@/extending.md#aliases) for the configuration format.
+
+### Examples
+
+Show the template for `deploy`:
+{{ terminal(cmd="wt config alias show deploy") }}
+
+Preview an invocation without running it:
+{{ terminal(cmd="wt config alias dry-run deploy|||wt config alias dry-run deploy -- --env=staging") }}
+
+### Command reference
+
+{% terminal() %}
+wt config alias - Inspect and preview aliases
+
+Usage: <b><span class=c>wt config alias</span></b> <span class=c>[OPTIONS]</span> <span class=c>&lt;COMMAND&gt;</span>
+
+<b><span class=g>Commands:</span></b>
+ <b><span class=c>show</span></b> Show an alias&#39;s template as configured
+ <b><span class=c>dry-run</span></b> Preview an alias invocation with template expansion
+
+<b><span class=g>Options:</span></b>
+ <b><span class=c>-h</span></b>, <b><span class=c>--help</span></b>
+ Print help (see a summary with &#39;-h&#39;)
+
+<b><span class=g>Global Options:</span></b>
+ <b><span class=c>-C</span></b><span class=c> &lt;path&gt;</span>
+ Working directory for this command
+
+ <b><span class=c>--config</span></b><span class=c> &lt;path&gt;</span>
+ User config file path
+
+ <b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
+ Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
+ + trace.log/output.log under .git/wt/logs/)
+
+ <b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
+ Skip approval prompts
+{% end %}
+
## wt config state
Manage internal data and cache.
diff --git a/docs/content/extending.md b/docs/content/extending.md
index cc9174f46..fe1a6ab66 100644
--- a/docs/content/extending.md
+++ b/docs/content/extending.md
@@ -116,7 +116,7 @@ deploy = "make deploy BRANCH={{ branch }} ENV={{ env }}"
open = "open http://localhost:{{ branch | hash_port }}"
```
-{{ terminal(cmd="wt deploy --env=staging|||wt deploy --dry-run --env=prod") }}
+{{ terminal(cmd="wt deploy|||wt deploy --env=staging") }}
`wt deploy` resolves `deploy` against configured aliases first, then falls through to a `wt-deploy` PATH binary if no alias matches. Built-in subcommands always take precedence — an alias named `list` or `switch` is unreachable.
@@ -132,7 +132,7 @@ Tokens after the alias name fall into one of these buckets, decided by what the
| Bare positional (no `--` prefix) | Forwarded to `{{ args }}` |
| Anything after a literal `--` | Forwarded to `{{ args }}` regardless of shape |
-Built-in flags (`--yes`/`-y`, `--dry-run`) are always recognized, so an alias can't shadow them. Built-in template variables (`branch`, `worktree_path`, `commit`, …) can be overridden — `--branch=override` for an alias referencing `{{ branch }}` binds to the user's value, but only inside the template; the worktree's actual branch is unchanged.
+Built-in template variables (`branch`, `worktree_path`, `commit`, …) can be overridden — `--branch=override` for an alias referencing `{{ branch }}` binds to the user's value, but only inside the template; the worktree's actual branch is unchanged.
Hyphens in variable names are canonicalized to underscores at parse time. `--my-var=value` binds to `{{ my_var }}` because minijinja parses `{{ my-var }}` as subtraction.
@@ -147,6 +147,17 @@ search = "rg {{ args }}"
{{ terminal(cmd="wt search -- --hidden --glob '*.rs' pattern # --hidden and --glob reach rg, not the alias parser") }}
+### Inspecting and previewing
+
+Two subcommands introspect aliases without running them:
+
+- `wt config alias show <name>` prints the configured template text, tagged by source (`user`/`project`).
+- `wt config alias dry-run <name> [-- args...]` parses the invocation with the same parser `wt <name>` uses, then prints the rendered command without executing.
+
+{{ terminal(cmd="wt config alias show deploy|||wt config alias dry-run deploy|||wt config alias dry-run deploy -- --env=staging") }}
+
+Arguments after `--` in `dry-run` are forwarded verbatim — `wt config alias dry-run s -- target-branch` previews exactly what `wt s target-branch` would run. Templates referencing `vars.*` are shown unexpanded, mirroring execution semantics: those values are read from git config just before each step runs.
+
### Forwarding positional arguments
Non-flag tokens after the alias name are forwarded to the template as `{{ args }}`. Bare `{{ args }}` renders as a space-joined, shell-escaped string ready to append to a command line — so `wt s some-branch` with `s = "wt switch {{ args }}"` expands to `wt switch some-branch`.
diff --git a/skills/worktrunk/reference/config.md b/skills/worktrunk/reference/config.md
index f8256741d..3db3508d6 100644
--- a/skills/worktrunk/reference/config.md
+++ b/skills/worktrunk/reference/config.md
@@ -481,6 +481,7 @@ Commands:
show Show configuration files & locations
update Update deprecated config settings
approvals Manage command approvals
+ alias Inspect and preview aliases
plugins Plugin management
state Manage internal data and cache
@@ -623,6 +624,55 @@ Global Options:
Skip approval prompts
```
+## wt config alias
+
+Inspect and preview aliases.
+
+Aliases are command templates configured in user (`~/.config/worktrunk/config.toml`) or project (`.config/wt.toml`) config and run as `wt <name>`. See [Aliases](https://worktrunk.dev/extending/#aliases) for the configuration format.
+
+### Examples
+
+Show the template for `deploy`:
+```bash
+$ wt config alias show deploy
+```
+
+Preview an invocation without running it:
+```bash
+$ wt config alias dry-run deploy
+$ wt config alias dry-run deploy -- --env=staging
+```
+
+### Command reference
+
+```
+wt config alias - Inspect and preview aliases
+
+Usage: wt config alias [OPTIONS] <COMMAND>
+
+Commands:
+ show Show an alias's template as configured
+ dry-run Preview an alias invocation with template expansion
+
+Options:
+ -h, --help
+ Print help (see a summary with '-h')
+
+Global Options:
+ -C <path>
+ Working directory for this command
+
+ --config <path>
+ User config file path
+
+ -v, --verbose...
+ Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
+ + trace.log/output.log under .git/wt/logs/)
+
+ -y, --yes
+ Skip approval prompts
+```
+
## wt config state
Manage internal data and cache.
diff --git a/skills/worktrunk/reference/extending.md b/skills/worktrunk/reference/extending.md
index 0e866040c..446c4db46 100644
--- a/skills/worktrunk/reference/extending.md
+++ b/skills/worktrunk/reference/extending.md
@@ -110,8 +110,8 @@ open = "open http://localhost:{{ branch | hash_port }}"
```
```bash
+wt deploy
wt deploy --env=staging
-wt deploy --dry-run --env=prod
```
`wt deploy` resolves `deploy` against configured aliases first, then falls through to a `wt-deploy` PATH binary if no alias matches. Built-in subcommands always take precedence — an alias named `list` or `switch` is unreachable.
@@ -128,7 +128,7 @@ Tokens after the alias name fall into one of these buckets, decided by what the
| Bare positional (no `--` prefix) | Forwarded to `{{ args }}` |
| Anything after a literal `--` | Forwarded to `{{ args }}` regardless of shape |
-Built-in flags (`--yes`/`-y`, `--dry-run`) are always recognized, so an alias can't shadow them. Built-in template variables (`branch`, `worktree_path`, `commit`, …) can be overridden — `--branch=override` for an alias referencing `{{ branch }}` binds to the user's value, but only inside the template; the worktree's actual branch is unchanged.
+Built-in template variables (`branch`, `worktree_path`, `commit`, …) can be overridden — `--branch=override` for an alias referencing `{{ branch }}` binds to the user's value, but only inside the template; the worktree's actual branch is unchanged.
Hyphens in variable names are canonicalized to underscores at parse time. `--my-var=value` binds to `{{ my_var }}` because minijinja parses `{{ my-var }}` as subtraction.
@@ -145,6 +145,21 @@ search = "rg {{ args }}"
wt search -- --hidden --glob '*.rs' pattern # --hidden and --glob reach rg, not the alias parser
```
+### Inspecting and previewing
+
+Two subcommands introspect aliases without running them:
+
+- `wt config alias show <name>` prints the configured template text, tagged by source (`user`/`project`).
+- `wt config alias dry-run <name> [-- args...]` parses the invocation with the same parser `wt <name>` uses, then prints the rendered command without executing.
+
+```bash
+wt config alias show deploy
+wt config alias dry-run deploy
+wt config alias dry-run deploy -- --env=staging
+```
+
+Arguments after `--` in `dry-run` are forwarded verbatim — `wt config alias dry-run s -- target-branch` previews exactly what `wt s target-branch` would run. Templates referencing `vars.*` are shown unexpanded, mirroring execution semantics: those values are read from git config just before each step runs.
+
### Forwarding positional arguments
Non-flag tokens after the alias name are forwarded to the template as `{{ args }}`. Bare `{{ args }}` renders as a space-joined, shell-escaped string ready to append to a command line — so `wt s some-branch` with `s = "wt switch {{ args }}"` expands to `wt switch some-branch`.
diff --git a/src/cli/config.rs b/src/cli/config.rs
index fd05557c0..ceba5b6c6 100644
--- a/src/cli/config.rs
+++ b/src/cli/config.rs
@@ -307,10 +307,65 @@ Skips gracefully if the statusline is already configured."#
InstallStatusline,
}
+// Ordering: introspection adjacent to invocation — show prints the template,
+// dry-run previews the expansion for a given invocation.
+#[derive(Subcommand)]
+pub enum ConfigAliasCommand {
+ /// Show an alias's template as configured
+ #[command(
+ after_long_help = r#"Prints each pipeline step's raw template indented with a gutter, tagged by source (user / project). Duplicate names defined in both configs show as two entries, runtime order (user first, then project).
+
+## Examples
+
+Show the template for `deploy`:
+```console
+$ wt config alias show deploy
+```"#
+ )]
+ Show {
+ /// Alias name
+ #[arg(add = crate::completion::alias_name_completer())]
+ name: String,
+ },
+
+ /// Preview an alias invocation with template expansion
+ #[command(
+ after_long_help = r#"Runs the same parser used at invocation time, applies template expansion (including `{{ args }}` and any `--var`/`--KEY=VALUE` assignments), and prints the resulting command without executing it. Templates referencing `vars.*` are shown unexpanded — those values resolve from git config at execution time, after earlier steps have had a chance to set them.
+
+Arguments after `--` are forwarded verbatim as if typed after `wt <name>`.
+
+## Examples
+
+Preview with no arguments:
+```console
+$ wt config alias dry-run deploy
+```
+
+Preview with positional args:
+```console
+$ wt config alias dry-run deploy -- staging us-east-1
+```
+
+Preview with a variable assignment:
+```console
+$ wt config alias dry-run deploy -- --env=staging
+```"#
+ )]
+ DryRun {
+ /// Alias name
+ #[arg(add = crate::completion::alias_name_completer())]
+ name: String,
+
+ /// Arguments forwarded to the alias as if typed after `wt <name>`
+ #[arg(last = true, allow_hyphen_values = true)]
+ args: Vec<String>,
+ },
+}
+
// Ordering: user journey — shell (install integration), create (bootstrap
// config files), show (inspect), update (migrate deprecations), approvals
-// (security policy for project commands), plugins (optional add-ons), state
-// (advanced diagnostics).
+// (security policy for project commands), aliases (inspect/preview user &
+// project aliases), plugins (optional add-ons), state (advanced diagnostics).
#[derive(Subcommand)]
pub enum ConfigCommand {
/// Shell integration setup
@@ -430,6 +485,28 @@ Approved commands are saved to `~/.config/worktrunk/approvals.toml`. Re-approval
action: ApprovalsCommand,
},
+ /// Inspect and preview aliases
+ #[command(
+ after_long_help = r#"Aliases are command templates configured in user (`~/.config/worktrunk/config.toml`) or project (`.config/wt.toml`) config and run as `wt <name>`. See [Aliases](@/extending.md#aliases) for the configuration format.
+
+## Examples
+
+Show the template for `deploy`:
+```console
+$ wt config alias show deploy
+```
+
+Preview an invocation without running it:
+```console
+$ wt config alias dry-run deploy
+$ wt config alias dry-run deploy -- --env=staging
+```"#
+ )]
+ Alias {
+ #[command(subcommand)]
+ action: ConfigAliasCommand,
+ },
+
/// Plugin management
#[command(
after_long_help = r#"Install and manage Worktrunk plugins for AI coding tools.
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 6202bfd8c..ecd7938dd 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -4,9 +4,10 @@ mod list;
mod step;
pub(crate) use config::{
- ApprovalsCommand, CiStatusAction, ConfigCommand, ConfigPluginsClaudeCommand,
- ConfigPluginsCommand, ConfigPluginsOpencodeCommand, ConfigShellCommand, DefaultBranchAction,
- HintsAction, LogsAction, MarkerAction, PreviousBranchAction, StateCommand, VarsAction,
+ ApprovalsCommand, CiStatusAction, ConfigAliasCommand, ConfigCommand,
+ ConfigPluginsClaudeCommand, ConfigPluginsCommand, ConfigPluginsOpencodeCommand,
+ ConfigShellCommand, DefaultBranchAction, HintsAction, LogsAction, MarkerAction,
+ PreviousBranchAction, StateCommand, VarsAction,
};
pub(crate) use hook::{HookCommand, rewrite_var_shorthand};
pub(crate) use list::ListSubcommand;
@@ -2086,6 +2087,7 @@ $ WORKTRUNK_COMMIT__GENERATION__COMMAND="echo 'test: automated commit'" wt merge
| `CLICOLOR_FORCE` | Force colored output even when not a TTY |
<!-- subdoc: show -->
<!-- subdoc: approvals -->
+<!-- subdoc: alias -->
<!-- subdoc: state -->"#)]
Config {
#[command(subcommand)]
diff --git a/src/commands/alias.rs b/src/commands/alias.rs
index da1f184f0..ebf1f5788 100644
--- a/src/commands/alias.rs
+++ b/src/commands/alias.rs
@@ -30,25 +30,25 @@
//! the EXEC directive file is scrubbed so alias bodies cannot inject
//! arbitrary shell into the interactive session.
-use std::collections::{BTreeMap, BTreeSet, HashMap};
+use std::collections::{BTreeMap, BTreeSet};
use anyhow::{Context, bail};
use clap::error::{ContextKind, ContextValue, ErrorKind};
use color_print::cformat;
use worktrunk::config::{
ALIAS_ARGS_KEY, CommandConfig, HookStep, ProjectConfig, UserConfig, append_aliases,
- referenced_vars_for_config, template_references_var, validate_template_syntax,
+ referenced_vars_for_config,
};
use worktrunk::git::Repository;
-use worktrunk::styling::{eprintln, format_bash_with_gutter, info_message, progress_message};
+use worktrunk::styling::{eprintln, progress_message};
use crate::commands::command_approval::approve_alias_commands;
use crate::commands::command_executor::{
CommandContext, CommandOrigin, FailureStrategy, ForegroundStep, PreparedCommand, PreparedStep,
- build_hook_context, execute_pipeline_foreground, expand_shell_template,
+ build_hook_context, execute_pipeline_foreground,
};
use crate::commands::did_you_mean;
-use crate::commands::hooks::format_pipeline_summary_from_names;
+use crate::commands::hooks::{format_pipeline_summary_from_names, step_names_from_config};
use crate::output::DirectivePassthrough;
/// Built-in `wt step` subcommand names. Aliases with these names are
@@ -80,11 +80,10 @@ const TOP_LEVEL_BUILTINS: &[&str] = &[
#[derive(Debug)]
pub struct AliasOptions {
pub name: String,
- pub dry_run: bool,
pub vars: Vec<(String, String)>,
/// Non-flag positional tokens passed after the alias name. Forwarded into
/// the template context as `{{ args }}` (a `ShellArgs` sequence). Appear
- /// in CLI order, interleaving freely with flags: `wt s foo --dry-run bar`
+ /// in CLI order, interleaving freely with flags: `wt s foo --env=prod bar`
/// collects `["foo", "bar"]`.
pub positional_args: Vec<String>,
}
@@ -99,7 +98,6 @@ impl AliasOptions {
///
/// - `--` — literal-forward escape: every later token goes straight into
/// `positional_args`, no var binding.
- /// - `--dry-run` — sets `dry_run`.
/// - `--KEY=VALUE` — binds `KEY=VALUE` if `KEY` is in `referenced_vars`,
/// otherwise forwards the whole `--KEY=VALUE` token as a positional.
/// - `--KEY VALUE` (separated by space, `VALUE` doesn't start with `--`)
@@ -117,6 +115,12 @@ impl AliasOptions {
/// propagate across `external_subcommand`, so the post-alias form
/// never reaches the global parser anyway.
///
+ /// `--dry-run` is no longer recognized — use `wt config alias dry-run <name>`
+ /// instead. The parser raises an actionable error pointing at the new
+ /// subcommand rather than silently forwarding the flag into `{{ args }}`.
+ /// The bail fires only outside `literal_mode`, so `wt alias -- --dry-run`
+ /// still forwards `--dry-run` as a positional.
+ ///
/// Hyphens in variable names are canonicalized to underscores before
/// lookup and storage (minijinja parses `{{ my-var }}` as subtraction),
/// so `--my-var=value` binds to `{{ my_var }}` when the template
@@ -130,7 +134,6 @@ impl AliasOptions {
bail!("Missing alias name");
};
- let mut dry_run = false;
let mut vars = Vec::new();
let mut positional_args = Vec::new();
let mut literal_mode = false;
@@ -148,9 +151,9 @@ impl AliasOptions {
continue;
}
if arg == "--dry-run" {
- dry_run = true;
- i += 1;
- continue;
+ bail!(
+ "--dry-run is no longer supported; use `wt config alias dry-run {name}` instead"
+ );
}
if let Some(rest) = arg.strip_prefix("--") {
if let Some((key, value)) = rest.split_once('=') {
@@ -187,7 +190,6 @@ impl AliasOptions {
Ok(Self {
name,
- dry_run,
vars,
positional_args,
})
@@ -263,15 +265,7 @@ fn unknown_step_command_exit(name: &str, alias_names: &[&str]) -> ! {
/// 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 {
- let step_names: Vec<Vec<Option<&str>>> = cmd_config
- .steps()
- .iter()
- .map(|step| match step {
- HookStep::Single(cmd) => vec![cmd.name.as_deref()],
- HookStep::Concurrent(cmds) => cmds.iter().map(|c| c.name.as_deref()).collect(),
- })
- .collect();
-
+ let step_names = step_names_from_config(cmd_config);
let summary =
format_pipeline_summary_from_names(&step_names, |n| cformat!("<bold>{n}</>"), |_| None);
@@ -404,19 +398,16 @@ fn run_alias(
.get(&opts.name)
.expect("caller verified alias is configured");
- let skip_approval = global_yes;
-
- // Check if this alias needs project-config approval (skip for --dry-run).
- // project_id is required for approval — re-derive with error propagation
- // rather than relying on `.ok()`.
- if !opts.dry_run
- && let Some(project_commands) = alias_needs_approval(&opts.name, &project_config)
- {
+ // Check if this alias needs project-config approval. project_id is required
+ // for approval — re-derive with error propagation rather than relying on
+ // `.ok()`. `global_yes` is the sole source for skipping approval now that
+ // `wt <alias> --yes` (post-alias form) is unsupported.
+ if let Some(project_commands) = alias_needs_approval(&opts.name, &project_config) {
let project_id = repo
.project_identifier()
.context("Cannot determine project identifier for alias approval")?;
let approved =
- approve_alias_commands(&project_commands, &opts.name, &project_id, skip_approval)?;
+ approve_alias_commands(&project_commands, &opts.name, &project_id, global_yes)?;
if !approved {
return Ok(());
}
@@ -447,26 +438,6 @@ fn run_alias(
let context_json = serde_json::to_string(&context_map)
.expect("HashMap<String, String> serialization should never fail");
- if opts.dry_run {
- let expanded: Vec<_> = cmd_config
- .commands()
- .map(|cmd| render_for_dry_run(&cmd.template, &context_map, &repo, &opts.name))
- .collect::<anyhow::Result<_>>()?;
- eprintln!(
- "{}",
- info_message(cformat!(
- "Alias <bold>{}</> would run:\n{}",
- opts.name,
- expanded
- .iter()
- .map(|c| format_bash_with_gutter(c))
- .collect::<Vec<_>>()
- .join("\n")
- ))
- );
- return Ok(());
- }
-
eprintln!(
"{}",
progress_message(format_alias_announcement(&opts.name, cmd_config))
@@ -512,30 +483,6 @@ fn run_alias(
)
}
-/// Render a command template for `--dry-run` display.
-///
-/// Mirrors execution-time lazy semantics: templates referencing `vars.*` may
-/// read values set by earlier pipeline steps via git config, and at dry-run
-/// time those values haven't been written yet (even if git config happens to
-/// hold a stale value from a previous run, the execution path would overwrite
-/// it). For those templates, syntax-validate (catching typos like
-/// `{{ vars..foo }}`) and show the raw template. Other templates expand
-/// eagerly against the initial context just like before.
-fn render_for_dry_run(
- template: &str,
- context: &HashMap<String, String>,
- repo: &Repository,
- alias_name: &str,
-) -> anyhow::Result<String> {
- if template_references_var(template, "vars") {
- validate_template_syntax(template, alias_name)
- .map_err(|e| anyhow::anyhow!("syntax error in alias {alias_name}: {e}"))?;
- Ok(template.to_string())
- } else {
- Ok(expand_shell_template(template, context, repo, alias_name)?)
- }
-}
-
/// Build a PreparedCommand for an alias, deferring template expansion to execution time.
fn alias_prepared_command(cmd: &worktrunk::config::Command, context_json: &str) -> PreparedCommand {
PreparedCommand {
@@ -550,11 +497,20 @@ fn alias_prepared_command(cmd: &worktrunk::config::Command, context_json: &str)
/// the listing shows both entries in runtime order (user first, then project)
/// rather than merging them, so users see the real commands from each source.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-enum AliasSource {
+pub(crate) enum AliasSource {
User,
Project,
}
+impl AliasSource {
+ pub(crate) fn label(self) -> &'static str {
+ match self {
+ AliasSource::User => "user",
+ AliasSource::Project => "project",
+ }
+ }
+}
+
/// Which help page is being augmented. Controls the "shadowed by built-in"
/// annotation: at the top level, only top-level built-ins shadow an alias
/// (`wt list` blocks an alias named `list`). Under `wt step`, only step
@@ -740,14 +696,7 @@ fn format_alias_summary(cfg: &CommandConfig) -> String {
// fall into the else branch and hide all but the first command. Count
// actual commands instead.
if cfg.commands().count() > 1 {
- let step_names: Vec<Vec<Option<&str>>> = cfg
- .steps()
- .iter()
- .map(|step| match step {
- HookStep::Single(cmd) => vec![cmd.name.as_deref()],
- HookStep::Concurrent(cmds) => cmds.iter().map(|c| c.name.as_deref()).collect(),
- })
- .collect();
+ let step_names = step_names_from_config(cfg);
let summary = format_pipeline_summary_from_names(&step_names, |n| n.to_string(), |_| None);
if summary.is_empty() {
format!("<{} steps>", cfg.commands().count())
@@ -864,16 +813,6 @@ cmd = [
assert_debug_snapshot!(parse(&["deploy"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
- vars: [],
- positional_args: [],
- }
- "#);
- // --dry-run is recognized regardless of referenced_vars.
- assert_debug_snapshot!(parse(&["deploy", "--dry-run"]).unwrap(), @r#"
- AliasOptions {
- name: "deploy",
- dry_run: true,
vars: [],
positional_args: [],
}
@@ -887,7 +826,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--env=staging"], &["env"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [
(
"env",
@@ -901,7 +839,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--env=staging"], &[]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"--env=staging",
@@ -912,7 +849,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--url=http://host?a=1"], &["url"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [
(
"url",
@@ -926,7 +862,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--env="], &["env"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [
(
"env",
@@ -940,7 +875,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--env="], &[]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"--env=",
@@ -956,7 +890,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--env", "staging"], &["env"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [
(
"env",
@@ -970,7 +903,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--env", "staging"], &[]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"--env",
@@ -983,7 +915,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--env", "--other"], &["env"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"--env",
@@ -995,7 +926,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--env"], &["env"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"--env",
@@ -1012,7 +942,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--my-var=value"], &["my_var"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [
(
"my_var",
@@ -1026,7 +955,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--my_var=value"], &["my_var"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [
(
"my_var",
@@ -1040,7 +968,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--region=us-east-1"], &["region"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [
(
"region",
@@ -1060,7 +987,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--env=staging", "--", "--env=other", "x"], &["env"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [
(
"env",
@@ -1078,7 +1004,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--", "--yes", "-y", "--dry-run"], &[]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"--yes",
@@ -1091,7 +1016,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--"], &[]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [],
}
@@ -1101,7 +1025,6 @@ cmd = [
assert_debug_snapshot!(parse_with(&["deploy", "--", "a", "--", "b"], &[]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"a",
@@ -1125,7 +1048,6 @@ cmd = [
@r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [
(
"env",
@@ -1151,7 +1073,6 @@ cmd = [
assert_debug_snapshot!(parse(&["s", "some-branch"]).unwrap(), @r#"
AliasOptions {
name: "s",
- dry_run: false,
vars: [],
positional_args: [
"some-branch",
@@ -1162,7 +1083,6 @@ cmd = [
assert_debug_snapshot!(parse(&["deploy", "one", "two", "three"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"one",
@@ -1171,12 +1091,16 @@ cmd = [
],
}
"#);
- // Built-in flags can interleave with positionals.
- assert_debug_snapshot!(parse(&["deploy", "foo", "--dry-run", "bar"]).unwrap(), @r#"
+ // Positionals can interleave with flags; flags bind when referenced, positionals keep order.
+ assert_debug_snapshot!(parse_with(&["deploy", "foo", "--env=prod", "bar"], &["env"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: true,
- vars: [],
+ vars: [
+ (
+ "env",
+ "prod",
+ ),
+ ],
positional_args: [
"foo",
"bar",
@@ -1188,7 +1112,6 @@ cmd = [
assert_debug_snapshot!(parse(&["deploy", "foo bar", "x;rm -rf /"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"foo bar",
@@ -1206,7 +1129,6 @@ cmd = [
assert_debug_snapshot!(parse(&["deploy", "--yes"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"--yes",
@@ -1216,7 +1138,6 @@ cmd = [
assert_debug_snapshot!(parse(&["deploy", "-y"]).unwrap(), @r#"
AliasOptions {
name: "deploy",
- dry_run: false,
vars: [],
positional_args: [
"-y",
@@ -1231,6 +1152,8 @@ cmd = [
assert_snapshot!(parse(&[]).unwrap_err(), @"Missing alias name");
// `--=value` has an empty key — caught even when bind would forward.
assert_snapshot!(parse(&["deploy", "--=value"]).unwrap_err(), @"invalid KEY=VALUE: key cannot be empty");
+ // Retired `--dry-run` flag gives an actionable error pointing at the new subcommand.
+ assert_snapshot!(parse(&["deploy", "--dry-run"]).unwrap_err(), @"--dry-run is no longer supported; use `wt config alias dry-run deploy` instead");
}
/// `referenced_vars_for_config` unions across pipeline steps so a var
diff --git a/src/commands/config/alias.rs b/src/commands/config/alias.rs
new file mode 100644
index 000000000..4b08721f9
--- /dev/null
+++ b/src/commands/config/alias.rs
@@ -0,0 +1,291 @@
+//! `wt config alias` subcommands.
+//!
+//! Introspection and preview for aliases configured in user config
+//! (`~/.config/worktrunk/config.toml`) and project config (`.config/wt.toml`).
+//! `show` prints the template text, source-labeled, with one gutter block per
+//! alias entry and `# <name>` comment lines above named pipeline steps.
+//! `dry-run` parses a per-invocation argument vector with the same parser
+//! `wt <alias>` uses, then expands templates using the same context as
+//! execution — so previews match what the real run will do. The two share a
+//! layout; only the header verb differs (`:` vs ` would run:`).
+//!
+//! ## Why `dry-run` lives here rather than on the alias dispatch
+//!
+//! Previous versions exposed dry-run via `wt <alias> --dry-run`. That routed
+//! through `AliasOptions::parse` and required every caller to handle the
+//! "preview vs run" branch. Lifting it into a dedicated subcommand keeps the
+//! alias-dispatch path single-purpose (always runs) and gives preview a
+//! natural home alongside `show`.
+
+use std::collections::{BTreeSet, HashMap};
+
+use anyhow::Context;
+use color_print::cformat;
+use worktrunk::config::{
+ ALIAS_ARGS_KEY, CommandConfig, ProjectConfig, UserConfig, append_aliases,
+ referenced_vars_for_config, template_references_var, validate_template_syntax,
+};
+use worktrunk::git::Repository;
+use worktrunk::styling::{format_bash_with_gutter, info_message, println};
+
+use crate::commands::alias::{AliasOptions, AliasSource};
+use crate::commands::command_executor::{
+ CommandContext, build_hook_context, expand_shell_template,
+};
+use crate::commands::did_you_mean;
+
+/// Show the configured template(s) for an alias, tagged by source.
+///
+/// When the same name is defined in both user and project config, both
+/// entries are printed (user first, matching runtime execution order).
+pub fn handle_alias_show(name: String) -> anyhow::Result<()> {
+ let repo = Repository::current()?;
+ let user_config = UserConfig::load()?;
+ let project_config = ProjectConfig::load(&repo, true)?;
+ let entries = entries_for_name(&repo, &user_config, project_config.as_ref(), &name);
+
+ if entries.is_empty() {
+ return Err(unknown_alias_error(
+ &repo,
+ &user_config,
+ project_config.as_ref(),
+ &name,
+ ));
+ }
+
+ for (i, (cfg, source)) in entries.iter().enumerate() {
+ if i > 0 {
+ println!();
+ }
+ let bodies: Vec<String> = cfg.commands().map(|c| c.template.clone()).collect();
+ println!("{}", format_entry(&name, cfg, *source, &bodies, None));
+ }
+ Ok(())
+}
+
+/// Preview an alias invocation: parse the args, build the template context,
+/// and print the rendered command(s) without executing.
+///
+/// Lazy semantics are preserved: templates referencing `vars.*` are shown
+/// raw (after syntax validation) because those values resolve from git
+/// config at execution time, potentially written by earlier pipeline steps.
+/// Other templates expand against the current context.
+pub fn handle_alias_dry_run(name: String, args: Vec<String>) -> anyhow::Result<()> {
+ let repo = Repository::current()?;
+ let user_config = UserConfig::load()?;
+ let project_config = ProjectConfig::load(&repo, true)?;
+ let entries = entries_for_name(&repo, &user_config, project_config.as_ref(), &name);
+
+ if entries.is_empty() {
+ return Err(unknown_alias_error(
+ &repo,
+ &user_config,
+ project_config.as_ref(),
+ &name,
+ ));
+ }
+
+ // Reuse the real parser so previews stay aligned with runtime parsing —
+ // including `--KEY=VALUE` routing and positional forwarding. When both
+ // user and project configs define the alias, union the referenced vars
+ // so a flag binds if any entry's template references it.
+ let mut referenced: BTreeSet<String> = BTreeSet::new();
+ for (cfg, _) in &entries {
+ referenced.extend(referenced_vars_for_config(cfg)?);
+ }
+ let mut parse_args = Vec::with_capacity(1 + args.len());
+ parse_args.push(name.clone());
+ parse_args.extend(args);
+ let opts = AliasOptions::parse(parse_args, &referenced)?;
+
+ let wt = repo.current_worktree();
+ let wt_path = wt.root().context("Failed to get worktree root")?;
+ let branch = wt.branch().ok().flatten();
+ let ctx = CommandContext::new(&repo, &user_config, branch.as_deref(), &wt_path, false);
+ let extra_refs: Vec<(&str, &str)> = opts
+ .vars
+ .iter()
+ .map(|(k, v)| (k.as_str(), v.as_str()))
+ .collect();
+ let mut context_map = build_hook_context(&ctx, &extra_refs)?;
+ context_map.insert(
+ ALIAS_ARGS_KEY.to_string(),
+ serde_json::to_string(&opts.positional_args)
+ .expect("Vec<String> serialization should never fail"),
+ );
+
+ for (i, (cfg, source)) in entries.iter().enumerate() {
+ if i > 0 {
+ println!();
+ }
+ let bodies: Vec<String> = cfg
+ .commands()
+ .map(|c| render_preview(&c.template, &context_map, &repo, &name))
+ .collect::<anyhow::Result<_>>()?;
+ println!(
+ "{}",
+ format_entry(&name, cfg, *source, &bodies, Some("would run"))
+ );
+ }
+ Ok(())
+}
+
+/// Render a single command template for preview. Mirrors execution-time lazy
+/// semantics — see the module-level docstring.
+fn render_preview(
+ template: &str,
+ context: &HashMap<String, String>,
+ repo: &Repository,
+ alias_name: &str,
+) -> anyhow::Result<String> {
+ if template_references_var(template, "vars") {
+ validate_template_syntax(template, alias_name)
+ .map_err(|e| anyhow::anyhow!("syntax error in alias {alias_name}: {e}"))?;
+ Ok(template.to_string())
+ } else {
+ Ok(expand_shell_template(template, context, repo, alias_name)?)
+ }
+}
+
+/// Resolve `name` against user + project config, preserving runtime execution
+/// order (user first, then project).
+fn entries_for_name(
+ repo: &Repository,
+ user_config: &UserConfig,
+ project_config: Option<&ProjectConfig>,
+ name: &str,
+) -> Vec<(CommandConfig, AliasSource)> {
+ let project_id = repo.project_identifier().ok();
+ let mut entries = Vec::new();
+ if let Some(cfg) = user_config.aliases(project_id.as_deref()).get(name) {
+ entries.push((cfg.clone(), AliasSource::User));
+ }
+ if let Some(pc) = project_config
+ && let Some(cfg) = pc.aliases.get(name)
+ {
+ entries.push((cfg.clone(), AliasSource::Project));
+ }
+ entries
+}
+
+/// Build an anyhow error for an unknown alias, with a clap-style "did you mean"
+/// tail pulled from the merged alias name set.
+///
+/// Uses `anyhow::Error::context` so the top-level handler formats the first
+/// line as a header and the suggestion list in the error gutter.
+fn unknown_alias_error(
+ repo: &Repository,
+ user_config: &UserConfig,
+ project_config: Option<&ProjectConfig>,
+ name: &str,
+) -> anyhow::Error {
+ let project_id = repo.project_identifier().ok();
+ let mut merged = user_config.aliases(project_id.as_deref());
+ if let Some(pc) = project_config {
+ append_aliases(&mut merged, &pc.aliases);
+ }
+ let suggestions = did_you_mean(name, merged.into_keys());
+ let header = format!("unknown alias '{name}'");
+ if suggestions.is_empty() {
+ anyhow::anyhow!(header)
+ } else {
+ let mut detail = String::from("a similar alias exists:");
+ for s in &suggestions {
+ detail.push_str(&format!("\n {s}"));
+ }
+ anyhow::Error::msg(detail).context(header)
+ }
+}
+
+/// Format one alias entry: `○ Alias <name> (<source>)[ <verb>]:` header
+/// followed by a single gutter block of the command bodies. Each named step
+/// gets a `# <name>` comment line above its body; anonymous steps render the
+/// body alone. Joining into one block matches the old `--dry-run` layout and
+/// keeps `show`/`dry-run` visually aligned — the only difference is the verb.
+fn format_entry(
+ name: &str,
+ cfg: &CommandConfig,
+ source: AliasSource,
+ bodies: &[String],
+ verb: Option<&str>,
+) -> String {
+ let label = source.label();
+ let suffix = match verb {
+ Some(v) => format!(" {v}:"),
+ None => ":".to_string(),
+ };
+ let mut body = String::new();
+ for (cmd, rendered) in cfg.commands().zip(bodies) {
+ if !body.is_empty() {
+ body.push('\n');
+ }
+ if let Some(step_name) = &cmd.name {
+ body.push_str(&format!("# {step_name}\n"));
+ }
+ body.push_str(rendered);
+ }
+ info_message(cformat!(
+ "Alias <bold>{name}</> ({label}){suffix}\n{}",
+ format_bash_with_gutter(&body)
+ ))
+ .to_string()
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use ansi_str::AnsiStr;
+
+ fn cfg_from_toml(toml_str: &str) -> CommandConfig {
+ #[derive(serde::Deserialize)]
+ struct Wrap {
+ cmd: CommandConfig,
+ }
+ toml::from_str::<Wrap>(toml_str).unwrap().cmd
+ }
+
+ #[test]
+ fn test_format_entry_show_single() {
+ let cfg = cfg_from_toml(r#"cmd = "echo {{ branch }}""#);
+ let bodies: Vec<String> = cfg.commands().map(|c| c.template.clone()).collect();
+ let out = format_entry("greet", &cfg, AliasSource::User, &bodies, None);
+ insta::assert_snapshot!(out.ansi_strip());
+ }
+
+ #[test]
+ fn test_format_entry_show_pipeline() {
+ let cfg = cfg_from_toml(
+ r#"
+cmd = [
+ { install = "npm install" },
+ { build = "npm run build", lint = "npm run lint" },
+]
+"#,
+ );
+ let bodies: Vec<String> = cfg.commands().map(|c| c.template.clone()).collect();
+ let out = format_entry("deploy", &cfg, AliasSource::Project, &bodies, None);
+ insta::assert_snapshot!(out.ansi_strip());
+ }
+
+ #[test]
+ fn test_format_entry_dry_run_pipeline() {
+ // The verb only changes the header suffix — body layout is identical.
+ let cfg = cfg_from_toml(
+ r#"
+cmd = [
+ { install = "npm install" },
+ { build = "npm run build", lint = "npm run lint" },
+]
+"#,
+ );
+ let bodies: Vec<String> = cfg.commands().map(|c| c.template.clone()).collect();
+ let out = format_entry(
+ "deploy",
+ &cfg,
+ AliasSource::Project,
+ &bodies,
+ Some("would run"),
+ );
+ insta::assert_snapshot!(out.ansi_strip());
+ }
+}
diff --git a/src/commands/config/mod.rs b/src/commands/config/mod.rs
index dd5c79413..59d4d12ad 100644
--- a/src/commands/config/mod.rs
+++ b/src/commands/config/mod.rs
@@ -2,6 +2,7 @@
//!
//! Commands for managing user config, project config, state, and hints.
+mod alias;
mod approvals;
mod create;
mod hints;
@@ -12,6 +13,7 @@ mod state;
mod update;
// Re-export public functions
+pub use alias::{handle_alias_dry_run, handle_alias_show};
pub use approvals::{add_approvals, clear_approvals};
pub use create::handle_config_create;
pub use hints::{handle_hints_clear, handle_hints_get};
diff --git a/src/commands/config/snapshots/wt__commands__config__alias__tests__format_entry_dry_run_pipeline.snap b/src/commands/config/snapshots/wt__commands__config__alias__tests__format_entry_dry_run_pipeline.snap
new file mode 100644
index 000000000..6bdc42345
--- /dev/null
+++ b/src/commands/config/snapshots/wt__commands__config__alias__tests__format_entry_dry_run_pipeline.snap
@@ -0,0 +1,11 @@
+---
+source: src/commands/config/alias.rs
+expression: out.ansi_strip()
+---
+○ Alias deploy (project) would run:
+ # install
+ npm install
+ # build
+ npm run build
+ # lint
+ npm run lint
diff --git a/src/commands/config/snapshots/wt__commands__config__alias__tests__format_entry_show_pipeline.snap b/src/commands/config/snapshots/wt__commands__config__alias__tests__format_entry_show_pipeline.snap
new file mode 100644
index 000000000..6971d9850
--- /dev/null
+++ b/src/commands/config/snapshots/wt__commands__config__alias__tests__format_entry_show_pipeline.snap
@@ -0,0 +1,11 @@
+---
+source: src/commands/config/alias.rs
+expression: out.ansi_strip()
+---
+○ Alias deploy (project):
+ # install
+ npm install
+ # build
+ npm run build
+ # lint
+ npm run lint
diff --git a/src/commands/config/snapshots/wt__commands__config__alias__tests__format_entry_show_single.snap b/src/commands/config/snapshots/wt__commands__config__alias__tests__format_entry_show_single.snap
new file mode 100644
index 000000000..8d03bf945
--- /dev/null
+++ b/src/commands/config/snapshots/wt__commands__config__alias__tests__format_entry_show_single.snap
@@ -0,0 +1,6 @@
+---
+source: src/commands/config/alias.rs
+expression: out.ansi_strip()
+---
+○ Alias greet (user):
+ echo {{ branch }}
diff --git a/src/commands/hooks.rs b/src/commands/hooks.rs
index 249ae6178..788ec9e28 100644
--- a/src/commands/hooks.rs
+++ b/src/commands/hooks.rs
@@ -147,6 +147,26 @@ pub struct SourcedStep {
pub is_pipeline: bool,
}
+/// Extract the per-step command name lists from a `CommandConfig`.
+///
+/// Shared by the formatters that describe alias / hook pipelines — `Single`
+/// steps become one-element inner vecs, `Concurrent` steps become multi-element
+/// vecs, each slot carrying the optional command name. Feeds directly into
+/// [`format_pipeline_summary_from_names`].
+pub(crate) fn step_names_from_config(
+ cfg: &worktrunk::config::CommandConfig,
+) -> Vec<Vec<Option<&str>>> {
+ cfg.steps()
+ .iter()
+ .map(|step| match step {
+ worktrunk::config::HookStep::Single(cmd) => vec![cmd.name.as_deref()],
+ worktrunk::config::HookStep::Concurrent(cmds) => {
+ cmds.iter().map(|c| c.name.as_deref()).collect()
+ }
+ })
+ .collect()
+}
+
/// Format a pipeline summary from per-step command names.
///
/// `step_names[i]` is the list of commands in step `i`; `Some(name)` for named
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 80ae8484a..3f27ef0a2 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -31,12 +31,12 @@ pub(crate) use alias::{
HelpContext, alias_names_for_suggestions, augment_help, step_alias, try_alias,
};
pub(crate) use config::{
- add_approvals, clear_approvals, handle_claude_install, handle_claude_install_statusline,
- handle_claude_uninstall, handle_config_create, handle_config_show, handle_config_update,
- handle_hints_clear, handle_hints_get, handle_logs_list, handle_opencode_install,
- handle_opencode_uninstall, handle_state_clear, handle_state_clear_all, handle_state_get,
- handle_state_set, handle_state_show, handle_vars_clear, handle_vars_get, handle_vars_list,
- handle_vars_set,
+ add_approvals, clear_approvals, handle_alias_dry_run, handle_alias_show, handle_claude_install,
+ handle_claude_install_statusline, handle_claude_uninstall, handle_config_create,
+ handle_config_show, handle_config_update, handle_hints_clear, handle_hints_get,
+ handle_logs_list, handle_opencode_install, handle_opencode_uninstall, handle_state_clear,
+ handle_state_clear_all, handle_state_get, handle_state_set, handle_state_show,
+ handle_vars_clear, handle_vars_get, handle_vars_list, handle_vars_set,
};
pub(crate) use configure_shell::{
handle_configure_shell, handle_show_theme, handle_unconfigure_shell,
diff --git a/src/completion.rs b/src/completion.rs
index aa5b1b3dc..9b639add6 100644
--- a/src/completion.rs
+++ b/src/completion.rs
@@ -225,6 +225,30 @@ pub(crate) fn hook_command_name_completer() -> ArgValueCompleter {
ArgValueCompleter::new(HookCommandCompleter)
}
+/// Alias name completion for `wt config alias <show|dry-run> <name>`.
+///
+/// Completes with the merged user + project alias name set. Returns all
+/// candidates unfiltered — the outer `maybe_handle_env_completion` does
+/// bash-specific prefix filtering; fish/zsh apply their own matching.
+pub(crate) fn alias_name_completer() -> ArgValueCompleter {
+ ArgValueCompleter::new(AliasNameCompleter)
+}
+
+#[derive(Clone, Copy)]
+struct AliasNameCompleter;
+
+impl ValueCompleter for AliasNameCompleter {
+ fn complete(&self, current: &OsStr) -> Vec<CompletionCandidate> {
+ if current.to_str().is_some_and(|s| s.starts_with('-')) {
+ return Vec::new();
+ }
+ load_aliases_for_completion()
+ .into_keys()
+ .map(CompletionCandidate::new)
+ .collect()
+ }
+}
+
#[derive(Clone, Copy)]
struct HookCommandCompleter;
diff --git a/src/main.rs b/src/main.rs
index 6e2f8d15e..d9967cad5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -47,26 +47,26 @@ use commands::repository_ext::RepositoryCliExt;
use commands::worktree::{handle_no_ff_merge, handle_push};
use commands::{
MergeOptions, OperationMode, RebaseResult, RemoveTarget, SquashResult, SwitchOptions,
- add_approvals, clear_approvals, handle_claude_install, handle_claude_install_statusline,
- handle_claude_uninstall, handle_completions, handle_config_create, handle_config_show,
- handle_config_update, handle_configure_shell, handle_custom_command, handle_hints_clear,
- handle_hints_get, handle_hook_show, handle_init, handle_list, handle_logs_list, handle_merge,
- handle_opencode_install, handle_opencode_uninstall, handle_promote, handle_rebase,
- handle_show_theme, handle_squash, handle_state_clear, handle_state_clear_all, handle_state_get,
- handle_state_set, handle_state_show, handle_switch, handle_unconfigure_shell,
- handle_vars_clear, handle_vars_get, handle_vars_list, handle_vars_set, resolve_worktree_arg,
- run_hook, step_commit, step_copy_ignored, step_diff, step_eval, step_for_each, step_prune,
- step_relocate,
+ add_approvals, clear_approvals, handle_alias_dry_run, handle_alias_show, handle_claude_install,
+ handle_claude_install_statusline, handle_claude_uninstall, handle_completions,
+ handle_config_create, handle_config_show, handle_config_update, handle_configure_shell,
+ handle_custom_command, handle_hints_clear, handle_hints_get, handle_hook_show, handle_init,
+ handle_list, handle_logs_list, handle_merge, handle_opencode_install,
+ handle_opencode_uninstall, handle_promote, handle_rebase, handle_show_theme, handle_squash,
+ handle_state_clear, handle_state_clear_all, handle_state_get, handle_state_set,
+ handle_state_show, handle_switch, handle_unconfigure_shell, handle_vars_clear, handle_vars_get,
+ handle_vars_list, handle_vars_set, resolve_worktree_arg, run_hook, step_commit,
+ step_copy_ignored, step_diff, step_eval, step_for_each, step_prune, step_relocate,
};
use output::handle_remove_output;
use worktrunk::git::BranchDeletionMode;
use cli::{
- ApprovalsCommand, CiStatusAction, Cli, Commands, ConfigCommand, ConfigPluginsClaudeCommand,
- ConfigPluginsCommand, ConfigPluginsOpencodeCommand, ConfigShellCommand, DefaultBranchAction,
- HintsAction, HookCommand, ListArgs, ListSubcommand, LogsAction, MarkerAction, MergeArgs,
- PreviousBranchAction, RemoveArgs, StateCommand, StepCommand, SwitchArgs, SwitchFormat,
- VarsAction,
+ ApprovalsCommand, CiStatusAction, Cli, Commands, ConfigAliasCommand, ConfigCommand,
+ ConfigPluginsClaudeCommand, ConfigPluginsCommand, ConfigPluginsOpencodeCommand,
+ ConfigShellCommand, DefaultBranchAction, HintsAction, HookCommand, ListArgs, ListSubcommand,
+ LogsAction, MarkerAction, MergeArgs, PreviousBranchAction, RemoveArgs, StateCommand,
+ StepCommand, SwitchArgs, SwitchFormat, VarsAction,
};
use worktrunk::HookType;
@@ -494,6 +494,10 @@ fn handle_config_command(action: ConfigCommand, yes: bool) -> anyhow::Result<()>
ApprovalsCommand::Add { all } => add_approvals(all),
ApprovalsCommand::Clear { global } => clear_approvals(global),
},
+ ConfigCommand::Alias { action } => match action {
+ ConfigAliasCommand::Show { name } => handle_alias_show(name),
+ ConfigAliasCommand::DryRun { name, args } => handle_alias_dry_run(name, args),
+ },
ConfigCommand::Plugins { action } => handle_plugins_command(action, yes),
ConfigCommand::State { action } => handle_state_command(action),
}
diff --git a/tests/integration_tests/completion.rs b/tests/integration_tests/completion.rs
index baa626cdf..4505df1f1 100644
--- a/tests/integration_tests/completion.rs
+++ b/tests/integration_tests/completion.rs
@@ -1404,6 +1404,41 @@ fn test_complete_single_dash_shows_both_short_and_long_flags(repo: TestRepo) {
}
}
+/// `wt config alias show <TAB>` and `wt config alias dry-run <TAB>` complete
+/// with the merged user + project alias name set.
+#[rstest]
+fn test_config_alias_name_completion(repo: TestRepo) {
+ repo.write_project_config(
+ r#"
+[aliases]
+deploy = "echo deploying"
+test = "cargo test"
+"#,
+ );
+ repo.commit("Add alias config");
+
+ for subcommand in ["show", "dry-run"] {
+ let output = repo
+ .completion_cmd(&["wt", "config", "alias", subcommand, ""])
+ .output()
+ .unwrap();
+ assert!(
+ output.status.success(),
+ "completion for `wt config alias {subcommand} <TAB>` failed"
+ );
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ let values = value_suggestions(&stdout);
+ assert!(
+ values.contains(&"deploy"),
+ "`wt config alias {subcommand}` should suggest configured aliases, got:\n{stdout}"
+ );
+ assert!(
+ values.contains(&"test"),
+ "`wt config alias {subcommand}` should suggest configured aliases, got:\n{stdout}"
+ );
+ }
+}
+
/// Test static shell completions command for package managers.
///
/// The `wt config shell completions <shell>` command outputs static completion
diff --git a/tests/integration_tests/output_system_guard.rs b/tests/integration_tests/output_system_guard.rs
index 38a3b4c3d..59b65d45e 100644
--- a/tests/integration_tests/output_system_guard.rs
+++ b/tests/integration_tests/output_system_guard.rs
@@ -36,6 +36,8 @@ const STDOUT_ALLOWED_PATHS: &[&str] = &[
"config/state.rs",
// Hint list output
"config/hints.rs",
+ // Alias introspection output (show / dry-run), intended to be pipeable
+ "config/alias.rs",
// Template evaluation output for scripting
"eval.rs",
// LLM prompt output for wt step commit --show-prompt
diff --git a/tests/integration_tests/step_alias.rs b/tests/integration_tests/step_alias.rs
index a57d88244..97a138cc6 100644
--- a/tests/integration_tests/step_alias.rs
+++ b/tests/integration_tests/step_alias.rs
@@ -33,9 +33,10 @@ hello = "echo Hello from {{ branch }}"
));
}
-/// --dry-run shows the expanded command without running it (no approval needed)
+/// `wt config alias dry-run <name>` shows the expanded command without running it
+/// (no approval needed — preview never executes project commands).
#[rstest]
-fn test_step_alias_dry_run(mut repo: TestRepo) {
+fn test_config_alias_dry_run(mut repo: TestRepo) {
repo.write_project_config(
r#"
[aliases]
@@ -48,11 +49,10 @@ hello = "echo Hello from {{ branch }}"
let settings = setup_snapshot_settings(&repo);
let _guard = settings.bind_to_scope();
- // No --yes needed: --dry-run skips approval
assert_cmd_snapshot!(make_snapshot_cmd(
&repo,
- "step",
- &["hello", "--dry-run"],
+ "config",
+ &["alias", "dry-run", "hello"],
Some(&feature_path),
));
}
@@ -136,12 +136,11 @@ greet = "echo Hello {{ name }} from {{ branch }}"
let settings = setup_snapshot_settings(&repo);
let _guard = settings.bind_to_scope();
- assert_cmd_snapshot!(make_snapshot_cmd_with_global_flags(
+ assert_cmd_snapshot!(make_snapshot_cmd(
&repo,
- "step",
- &["greet", "--dry-run", "--name=World"],
+ "config",
+ &["alias", "dry-run", "greet", "--", "--name=World"],
Some(&feature_path),
- &["-y"],
));
}
@@ -161,12 +160,11 @@ greet = "echo Hello {{ name }} from {{ branch }}"
let settings = setup_snapshot_settings(&repo);
let _guard = settings.bind_to_scope();
- assert_cmd_snapshot!(make_snapshot_cmd_with_global_flags(
+ assert_cmd_snapshot!(make_snapshot_cmd(
&repo,
- "step",
- &["greet", "--dry-run", "--name", "World"],
+ "config",
+ &["alias", "dry-run", "greet", "--", "--name", "World"],
Some(&feature_path),
- &["-y"],
));
}
@@ -446,28 +444,32 @@ shared = "echo user-version"
"user_alias",
make_snapshot_cmd(
&repo,
- "step",
- &["user-cmd", "--dry-run"],
+ "config",
+ &["alias", "dry-run", "user-cmd"],
Some(&feature_path),
)
);
- // Project alias available (-y bypasses approval for project-config aliases)
+ // Project alias available — dry-run never needs approval (it doesn't execute).
assert_cmd_snapshot!(
"project_alias",
- make_snapshot_cmd_with_global_flags(
+ make_snapshot_cmd(
&repo,
- "step",
- &["project-cmd", "--dry-run"],
+ "config",
+ &["alias", "dry-run", "project-cmd"],
Some(&feature_path),
- &["-y"],
)
);
- // Both run on collision: user first, then project (append semantics)
+ // Both definitions visible on collision: user first, then project (matches runtime order).
assert_cmd_snapshot!(
"user_and_project_append",
- make_snapshot_cmd(&repo, "step", &["shared", "--dry-run"], Some(&feature_path),)
+ make_snapshot_cmd(
+ &repo,
+ "config",
+ &["alias", "dry-run", "shared"],
+ Some(&feature_path),
+ )
);
}
@@ -1154,12 +1156,12 @@ deploy = [
);
}
-/// `--dry-run` for a pipeline where a later step references `{{ vars.X }}`
-/// set by an earlier step succeeds, mirroring the lazy execution path. The
-/// unresolved `vars.*` reference is shown as the raw template since its value
-/// isn't knowable until the earlier step actually runs.
+/// `dry-run` for a pipeline where a later step references `{{ vars.X }}` set by
+/// an earlier step succeeds, mirroring the lazy execution path. The unresolved
+/// `vars.*` reference is shown as the raw template since its value isn't
+/// knowable until the earlier step actually runs.
#[rstest]
-fn test_step_alias_dry_run_vars_across_steps(mut repo: TestRepo) {
+fn test_config_alias_dry_run_vars_across_steps(mut repo: TestRepo) {
repo.write_project_config(
r#"
[aliases]
@@ -1176,20 +1178,18 @@ deploy = [
let _guard = settings.bind_to_scope();
// Must succeed: dry-run must not require vars.* to be resolvable.
- // -y bypasses approval for project-config aliases.
- assert_cmd_snapshot!(make_snapshot_cmd_with_global_flags(
+ assert_cmd_snapshot!(make_snapshot_cmd(
&repo,
- "step",
- &["deploy", "--dry-run"],
+ "config",
+ &["alias", "dry-run", "deploy"],
Some(&feature_path),
- &["-y"],
));
}
-/// `--dry-run` still catches template syntax errors (e.g., `{{ vars..foo }}`)
-/// even on the lazy path where `vars.*` rendering is skipped.
+/// `dry-run` still catches template syntax errors (e.g., `{{ vars..foo }}`) even
+/// on the lazy path where `vars.*` rendering is skipped.
#[rstest]
-fn test_step_alias_dry_run_catches_syntax_error(mut repo: TestRepo) {
+fn test_config_alias_dry_run_catches_syntax_error(mut repo: TestRepo) {
repo.write_project_config(
r#"
[aliases]
@@ -1201,7 +1201,7 @@ broken = "echo {{ vars..target }}"
let output = repo
.wt_command()
- .args(["-y", "step", "broken", "--dry-run"])
+ .args(["config", "alias", "dry-run", "broken"])
.current_dir(&feature_path)
.output()
.unwrap();
@@ -1216,6 +1216,185 @@ broken = "echo {{ vars..target }}"
);
}
+/// Retired `wt <alias> --dry-run` flag produces an actionable error pointing at
+/// the new subcommand. Snapshots the top-level path; the shared parser covers
+/// both `wt <alias>` and `wt step <alias>` dispatch routes (unit test in
+/// `commands::alias::tests::test_parse_errors` verifies the message verbatim).
+#[rstest]
+fn test_retired_dry_run_flag(mut repo: TestRepo) {
+ repo.write_project_config(
+ r#"
+[aliases]
+deploy = "echo hi"
+"#,
+ );
+ repo.commit("Add alias config");
+ let feature_path = repo.add_worktree("feature");
+
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "deploy",
+ &["--dry-run"],
+ Some(&feature_path),
+ ));
+}
+
+/// `wt config alias show <name>` prints the configured template text, source-labeled.
+#[rstest]
+fn test_config_alias_show_single(mut repo: TestRepo) {
+ repo.write_project_config(
+ r#"
+[aliases]
+deploy = "make deploy BRANCH={{ branch }}"
+"#,
+ );
+ repo.commit("Add alias config");
+ let feature_path = repo.add_worktree("feature");
+
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "config",
+ &["alias", "show", "deploy"],
+ Some(&feature_path),
+ ));
+}
+
+/// Unknown alias name triggers a did-you-mean suggestion.
+#[rstest]
+fn test_config_alias_show_unknown_suggests(mut repo: TestRepo) {
+ repo.write_project_config(
+ r#"
+[aliases]
+deploy = "make deploy"
+hello = "echo hi"
+"#,
+ );
+ repo.commit("Add alias config");
+ let feature_path = repo.add_worktree("feature");
+
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "config",
+ &["alias", "show", "deplyo"],
+ Some(&feature_path),
+ ));
+}
+
+/// Multi-step pipeline renders with per-step structure in the header.
+#[rstest]
+fn test_config_alias_show_pipeline(mut repo: TestRepo) {
+ repo.write_project_config(
+ r#"
+[[aliases.release]]
+install = "npm install"
+
+[[aliases.release]]
+build = "npm run build"
+lint = "npm run lint"
+"#,
+ );
+ repo.commit("Add alias config");
+ let feature_path = repo.add_worktree("feature");
+
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "config",
+ &["alias", "show", "release"],
+ Some(&feature_path),
+ ));
+}
+
+/// Positional args via `wt config alias dry-run <name> -- foo bar` flow through as `{{ args }}`.
+#[rstest]
+fn test_config_alias_dry_run_positional_args(mut repo: TestRepo) {
+ repo.write_project_config(
+ r#"
+[aliases]
+s = "wt switch {{ args }}"
+"#,
+ );
+ repo.commit("Add alias config");
+ let feature_path = repo.add_worktree("feature");
+
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "config",
+ &["alias", "dry-run", "s", "--", "target-branch"],
+ Some(&feature_path),
+ ));
+}
+
+/// `wt config alias show <name>` with the same alias defined in both user and
+/// project config prints both entries in runtime order (user first).
+#[rstest]
+fn test_config_alias_show_user_and_project(mut repo: TestRepo) {
+ repo.write_project_config(
+ r#"
+[aliases]
+deploy = "echo from project"
+"#,
+ );
+ repo.commit("Add alias config");
+ let feature_path = repo.add_worktree("feature");
+ repo.write_test_config(
+ r#"
+[aliases]
+deploy = "echo from user"
+"#,
+ );
+
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "config",
+ &["alias", "show", "deploy"],
+ Some(&feature_path),
+ ));
+}
+
+/// Unknown alias name with no similar configured aliases shows a plain error
+/// without a "did you mean" tail.
+#[rstest]
+fn test_config_alias_show_unknown_no_suggestions(mut repo: TestRepo) {
+ repo.write_project_config(
+ r#"
+[aliases]
+deploy = "echo hi"
+"#,
+ );
+ repo.commit("Add alias config");
+ let feature_path = repo.add_worktree("feature");
+
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ // Query name shares no meaningful prefix with any configured alias — the
+ // Jaro-Winkler threshold rejects it, so the error has no suggestion list.
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "config",
+ &["alias", "show", "zzzzzzzz"],
+ Some(&feature_path),
+ ));
+}
+
/// `wt step` with no subcommand lists built-in steps plus configured aliases.
///
/// Skipped on Windows: clap renders `[experimental]` subcommand tags
@@ -1423,8 +1602,8 @@ run = "echo [{{ args }}]"
}
/// `wt s some-branch` with `s = "wt switch {{ args }}"` forwards the
-/// positional into the expanded command. Verified via `--dry-run` so the
-/// inner `wt switch` is not actually executed.
+/// positional into the expanded command. Verified via `wt config alias dry-run`
+/// so the inner `wt switch` is not actually executed.
#[rstest]
fn test_top_level_alias_positional_expands_in_dry_run(mut repo: TestRepo) {
repo.write_project_config(
@@ -1439,12 +1618,11 @@ s = "wt switch {{ args }}"
let settings = setup_snapshot_settings(&repo);
let _guard = settings.bind_to_scope();
- assert_cmd_snapshot!(make_snapshot_cmd_with_global_flags(
+ assert_cmd_snapshot!(make_snapshot_cmd(
&repo,
- "s",
- &["target-branch", "--dry-run"],
+ "config",
+ &["alias", "dry-run", "s", "--", "target-branch"],
Some(&feature_path),
- &["-y"],
));
}
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_long.snap b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
index 624a13359..507657fe3 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
@@ -42,6 +42,7 @@ Usage: wt config [OPTIONS] <COMMAND>
show Show configuration files & locations
update Update deprecated config settings
approvals Manage command approvals
+ alias Inspect and preview aliases
plugins Plugin management
state Manage internal data and cache
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_short.snap b/tests/snapshots/integration__integration_tests__help__help_config_short.snap
index 761d6f543..c6c0bc75d 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_short.snap
@@ -40,6 +40,7 @@ Usage: wt config [OPTIONS] <COMMAND>
show Show configuration files & locations
update Update deprecated config settings
approvals Manage command approvals
+ alias Inspect and preview aliases
plugins Plugin management
state Manage internal data and cache
diff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_dry_run.snap b/tests/snapshots/integration__integration_tests__step_alias__config_alias_dry_run.snap
similarity index 93%
rename from tests/snapshots/integration__integration_tests__step_alias__step_alias_dry_run.snap
rename to tests/snapshots/integration__integration_tests__step_alias__config_alias_dry_run.snap
index e6f0c9817..579b8f33f 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_dry_run.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__config_alias_dry_run.snap
@@ -3,9 +3,10 @@ source: tests/integration_tests/step_alias.rs
info:
program: wt
args:
- - step
+ - config
+ - alias
+ - dry-run
- hello
- - "--dry-run"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -43,7 +44,7 @@ info:
success: true
exit_code: 0
----- stdout -----
+○ Alias hello (project) would run:
+  echo Hello from feature
----- stderr -----
-○ Alias hello would run:
-  echo Hello from feature
diff --git a/tests/snapshots/integration__integration_tests__step_alias__config_alias_dry_run_positional_args.snap b/tests/snapshots/integration__integration_tests__step_alias__config_alias_dry_run_positional_args.snap
new file mode 100644
index 000000000..03f52e6c3
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_alias__config_alias_dry_run_positional_args.snap
@@ -0,0 +1,52 @@
+---
+source: tests/integration_tests/step_alias.rs
+info:
+ program: wt
+ args:
+ - config
+ - alias
+ - dry-run
+ - s
+ - "--"
+ - target-branch
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+○ Alias s (project) would run:
+  wt switch target-branch
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_dry_run_vars_across_steps.snap b/tests/snapshots/integration__integration_tests__step_alias__config_alias_dry_run_vars_across_steps.snap
similarity index 91%
rename from tests/snapshots/integration__integration_tests__step_alias__step_alias_dry_run_vars_across_steps.snap
rename to tests/snapshots/integration__integration_tests__step_alias__config_alias_dry_run_vars_across_steps.snap
index bc8ec58c2..54465cdfa 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_dry_run_vars_across_steps.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__config_alias_dry_run_vars_across_steps.snap
@@ -3,10 +3,10 @@ source: tests/integration_tests/step_alias.rs
info:
program: wt
args:
- - step
+ - config
+ - alias
+ - dry-run
- deploy
- - "--dry-run"
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -44,8 +44,9 @@ info:
success: true
exit_code: 0
----- stdout -----
-
------ stderr -----
-○ Alias deploy would run:
+○ Alias deploy (project) would run:
  git config worktrunk.state.main.vars.target 'prod'
+  # publish
  echo deploying to {{ vars.target }}
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_pipeline.snap b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_pipeline.snap
new file mode 100644
index 000000000..67a8ffc6b
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_pipeline.snap
@@ -0,0 +1,55 @@
+---
+source: tests/integration_tests/step_alias.rs
+info:
+ program: wt
+ args:
+ - config
+ - alias
+ - show
+ - release
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+○ Alias release (project):
+  # install
+  npm install
+  # build
+  npm run build
+  # lint
+  npm run lint
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_single.snap b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_single.snap
new file mode 100644
index 000000000..98517cad6
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_single.snap
@@ -0,0 +1,50 @@
+---
+source: tests/integration_tests/step_alias.rs
+info:
+ program: wt
+ args:
+ - config
+ - alias
+ - show
+ - deploy
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+○ Alias deploy (project):
+  make deploy BRANCH={{ branch }}
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_unknown_no_suggestions.snap b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_unknown_no_suggestions.snap
new file mode 100644
index 000000000..9293dd1fe
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_unknown_no_suggestions.snap
@@ -0,0 +1,49 @@
+---
+source: tests/integration_tests/step_alias.rs
+info:
+ program: wt
+ args:
+ - config
+ - alias
+ - show
+ - zzzzzzzz
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: false
+exit_code: 1
+----- stdout -----
+
+----- stderr -----
+✗ unknown alias 'zzzzzzzz'
diff --git a/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_unknown_suggests.snap b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_unknown_suggests.snap
new file mode 100644
index 000000000..62e1a120d
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_unknown_suggests.snap
@@ -0,0 +1,52 @@
+---
+source: tests/integration_tests/step_alias.rs
+info:
+ program: wt
+ args:
+ - config
+ - alias
+ - show
+ - deplyo
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: false
+exit_code: 1
+----- stdout -----
+
+----- stderr -----
+✗ unknown alias 'deplyo'
+  a similar alias exists:
+  deploy
+  hello
diff --git a/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_user_and_project.snap b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_user_and_project.snap
new file mode 100644
index 000000000..d0f4a57b0
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_user_and_project.snap
@@ -0,0 +1,53 @@
+---
+source: tests/integration_tests/step_alias.rs
+info:
+ program: wt
+ args:
+ - config
+ - alias
+ - show
+ - deploy
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+○ Alias deploy (user):
+  echo from user
+
+○ Alias deploy (project):
+  echo from project
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_alias__project_alias.snap b/tests/snapshots/integration__integration_tests__step_alias__project_alias.snap
index e0c06c3dc..33d63e4c6 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__project_alias.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__project_alias.snap
@@ -3,10 +3,10 @@ source: tests/integration_tests/step_alias.rs
info:
program: wt
args:
- - step
+ - config
+ - alias
+ - dry-run
- project-cmd
- - "--dry-run"
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -44,7 +44,7 @@ info:
success: true
exit_code: 0
----- stdout -----
+○ Alias project-cmd (project) would run:
+  echo from-project
----- stderr -----
-○ Alias project-cmd would run:
-  echo from-project
diff --git a/tests/snapshots/integration__integration_tests__step_alias__retired_dry_run_flag.snap b/tests/snapshots/integration__integration_tests__step_alias__retired_dry_run_flag.snap
new file mode 100644
index 000000000..1b67593ac
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_alias__retired_dry_run_flag.snap
@@ -0,0 +1,47 @@
+---
+source: tests/integration_tests/step_alias.rs
+info:
+ program: wt
+ args:
+ - deploy
+ - "--dry-run"
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: false
+exit_code: 1
+----- stdout -----
+
+----- stderr -----
+✗ --dry-run is no longer supported; use `wt config alias dry-run deploy` instead
diff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_binds_referenced_var.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_binds_referenced_var.snap
index 7b0730d85..a38698b01 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_binds_referenced_var.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_binds_referenced_var.snap
@@ -3,11 +3,12 @@ source: tests/integration_tests/step_alias.rs
info:
program: wt
args:
- - step
+ - config
+ - alias
+ - dry-run
- greet
- - "--dry-run"
+ - "--"
- "--name=World"
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -45,7 +46,7 @@ info:
success: true
exit_code: 0
----- stdout -----
+○ Alias greet (project) would run:
+  echo Hello World from feature
----- stderr -----
-○ Alias greet would run:
-  echo Hello World from feature
diff --git a/tests/snapshots/integration__integration_tests__step_alias__step_alias_binds_space_separated_var.snap b/tests/snapshots/integration__integration_tests__step_alias__step_alias_binds_space_separated_var.snap
index b9a37ddab..33a4c34fa 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__step_alias_binds_space_separated_var.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__step_alias_binds_space_separated_var.snap
@@ -3,12 +3,13 @@ source: tests/integration_tests/step_alias.rs
info:
program: wt
args:
- - step
+ - config
+ - alias
+ - dry-run
- greet
- - "--dry-run"
+ - "--"
- "--name"
- World
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -46,7 +47,7 @@ info:
success: true
exit_code: 0
----- stdout -----
+○ Alias greet (project) would run:
+  echo Hello World from feature
----- stderr -----
-○ Alias greet would run:
-  echo Hello World from feature
diff --git a/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_positional_expands_in_dry_run.snap b/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_positional_expands_in_dry_run.snap
index e64e7b506..03f52e6c3 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_positional_expands_in_dry_run.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__top_level_alias_positional_expands_in_dry_run.snap
@@ -3,10 +3,12 @@ source: tests/integration_tests/step_alias.rs
info:
program: wt
args:
+ - config
+ - alias
+ - dry-run
- s
+ - "--"
- target-branch
- - "--dry-run"
- - "--yes"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -44,7 +46,7 @@ info:
success: true
exit_code: 0
----- stdout -----
+○ Alias s (project) would run:
+  wt switch target-branch
----- stderr -----
-○ Alias s would run:
-  wt switch target-branch
diff --git a/tests/snapshots/integration__integration_tests__step_alias__user_alias.snap b/tests/snapshots/integration__integration_tests__step_alias__user_alias.snap
index 96dd3db3b..29b2e68cc 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__user_alias.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__user_alias.snap
@@ -3,9 +3,10 @@ source: tests/integration_tests/step_alias.rs
info:
program: wt
args:
- - step
+ - config
+ - alias
+ - dry-run
- user-cmd
- - "--dry-run"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -43,7 +44,7 @@ info:
success: true
exit_code: 0
----- stdout -----
+○ Alias user-cmd (user) would run:
+  echo from-user
----- stderr -----
-○ Alias user-cmd would run:
-  echo from-user
diff --git a/tests/snapshots/integration__integration_tests__step_alias__user_and_project_append.snap b/tests/snapshots/integration__integration_tests__step_alias__user_and_project_append.snap
index 55ee17db3..166ff14d7 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__user_and_project_append.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__user_and_project_append.snap
@@ -3,9 +3,10 @@ source: tests/integration_tests/step_alias.rs
info:
program: wt
args:
- - step
+ - config
+ - alias
+ - dry-run
- shared
- - "--dry-run"
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
@@ -43,8 +44,10 @@ info:
success: true
exit_code: 0
----- stdout -----
-
------ stderr -----
-○ Alias shared would run:
+○ Alias shared (user) would run:
  echo user-version
+
+○ Alias shared (project) would run:
  echo project-version
+
+----- stderr -----