Skip to content

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

Refactor ForEach help text and improve lychee caching config

Maximilian Roos12b74cd9f55f
diff --git a/.config/lychee.toml b/.config/lychee.toml
index 307d9ee75..1a2e8fbd9 100644
--- a/.config/lychee.toml
+++ b/.config/lychee.toml
@@ -12,6 +12,7 @@ accept = [200, 206, 429]
# Caching to reduce rate limiting and improve performance
cache = true
max_cache_age = "1d"
+cache_exclude_status = "400..=599" # Don't cache errors (only successes)
# Exclude sites that block GitHub Actions or have reliability issues
exclude = [
diff --git a/src/cli.rs b/src/cli.rs
index ea982fed3..af2746bab 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -617,53 +617,58 @@ pub enum StepCommand {
},
/// \[experimental\] Run command in each worktree
- ///
- /// Executes a command sequentially in every worktree with real-time output.
- /// Continues on failure and shows a summary at the end.
- ///
- /// Context JSON is piped to stdin for scripts that need structured data.
- ///
- /// Supports template variables (all shell-escaped):
- ///
- /// - `{{ branch }}` — branch name (slashes replaced with dashes)
- /// - `{{ worktree }}` — absolute path to the worktree
- /// - `{{ worktree_name }}` — worktree directory name
- /// - `{{ repo }}` — repository name
- /// - `{{ repo_root }}` — absolute path to the main repository root
- /// - `{{ commit }}` — current HEAD commit SHA (full)
- /// - `{{ short_commit }}` — current HEAD commit SHA (7 chars)
- /// - `{{ default_branch }}` — default branch name (e.g., "main")
- /// - `{{ remote }}` — primary remote name (e.g., "origin")
- /// - `{{ remote_url }}` — primary remote URL
- /// - `{{ upstream }}` — upstream tracking branch, if configured
- ///
- /// Note: This command is experimental and may change in future versions.
- ///
- /// # Examples
- ///
- /// Check status across all worktrees:
- ///
- /// ```text
- /// wt step for-each -- git status --short
- /// ```
- ///
- /// Run npm install in all worktrees:
- ///
- /// ```text
- /// wt step for-each -- npm install
- /// ```
- ///
- /// Use branch name in command:
- ///
- /// ```text
- /// wt step for-each -- "echo Branch: {{ branch }}"
- /// ```
- ///
- /// Pull updates in worktrees with upstreams (skips others):
- ///
- /// ```text
- /// wt step for-each -- '[ "$(git rev-parse @{u} 2>/dev/null)" ] || exit 0; git pull --autostash'
- /// ```
+ #[command(
+ after_long_help = r#"Executes a command sequentially in every worktree with real-time output. Continues on failure and shows a summary at the end.
+
+Context JSON is piped to stdin for scripts that need structured data.
+
+## Template variables
+
+All variables are shell-escaped:
+
+| Variable | Description |
+|----------|-------------|
+| `{{ branch }}` | Branch name (slashes replaced with dashes) |
+| `{{ worktree }}` | Absolute path to the worktree |
+| `{{ worktree_name }}` | Worktree directory name |
+| `{{ repo }}` | Repository name |
+| `{{ repo_root }}` | Absolute path to the main repository root |
+| `{{ commit }}` | Current HEAD commit SHA (full) |
+| `{{ short_commit }}` | Current HEAD commit SHA (7 chars) |
+| `{{ default_branch }}` | Default branch name (e.g., "main") |
+| `{{ remote }}` | Primary remote name (e.g., "origin") |
+| `{{ remote_url }}` | Primary remote URL |
+| `{{ upstream }}` | Upstream tracking branch, if configured |
+
+## Examples
+
+Check status across all worktrees:
+
+```console
+wt step for-each -- git status --short
+```
+
+Run npm install in all worktrees:
+
+```console
+wt step for-each -- npm install
+```
+
+Use branch name in command:
+
+```console
+wt step for-each -- "echo Branch: {{ branch }}"
+```
+
+Pull updates in worktrees with upstreams (skips others):
+
+```console
+wt step for-each -- '[ "$(git rev-parse @{u} 2>/dev/null)" ] || exit 0; git pull --autostash'
+```
+
+Note: This command is experimental and may change in future versions.
+"#
+ )]
ForEach {
/// Command template (see --help for all variables)
#[arg(required = true, last = true, num_args = 1..)]