Skip to content

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

fix(output): finish the "to X, run Y" sweep and give the default-branch error one form (#4155)

Maximilian Roos32940482e1f9
diff --git a/.claude/skills/writing-user-outputs/SKILL.md b/.claude/skills/writing-user-outputs/SKILL.md
index 6c1515f44..791db1a1d 100644
--- a/.claude/skills/writing-user-outputs/SKILL.md
+++ b/.claude/skills/writing-user-outputs/SKILL.md
@@ -230,8 +230,8 @@ address the user. Imperatives like "Run", "Use", "Add" are fine — they're
concise CLI idiom.
```rust
-// BAD - "Use 'wt merge' to rebase your changes onto main"
-// GOOD - "Use 'wt merge' to rebase onto main"
+// BAD - "To rebase your changes onto main, run wt merge"
+// GOOD - "To rebase onto main, run wt merge"
```
**Avoid redundant parenthesized content:** Parenthesized text should add new
@@ -292,10 +292,10 @@ mentioned in the error message.
```rust
// BAD - "it" refers to branch name in error message
// Error: "Branch 'feature' not found"
-// Hint: "Use --create to create it"
+// Hint: "To create it, use --create"
// GOOD - self-contained hint
// Error: "Branch 'feature' not found"
-// Hint: "Use --create to create a new branch"
+// Hint: "To create a new branch, use --create"
```
## Heading Case
@@ -763,7 +763,7 @@ Use `eprintln!` with formatting functions. Use `cformat!` for inner styling:
```rust
eprintln!("{}", success_message(cformat!("Created <bold>{branch}</> from <bold>{base}</>")));
-eprintln!("{}", hint_message(cformat!("Run <underline>wt merge</> to continue")));
+eprintln!("{}", hint_message(cformat!("To continue, run <underline>wt merge</>")));
```
**color-print tags:** `<bold>`, `<dim>`, `<underline>`, `<bright-black>`, `<red>`,
@@ -790,11 +790,11 @@ Never quote commands or branch names. Use styling to make them stand out:
```rust
// GOOD - bold in normal context
-eprintln!("{}", info_message(cformat!("Use <bold>wt merge</> to continue")));
+eprintln!("{}", info_message(cformat!("To continue, use <bold>wt merge</>")));
// GOOD - underline for commands in hints
-eprintln!("{}", hint_message(cformat!("Run <underline>wt list</> to see worktrees")));
+eprintln!("{}", hint_message(cformat!("To see worktrees, run <underline>wt list</>")));
// BAD - quoted commands
-eprintln!("{}", hint_message("Run 'wt list' to see worktrees"));
+eprintln!("{}", hint_message("To see worktrees, run 'wt list'"));
```
## Hyperlinks
diff --git a/src/commands/config/state.rs b/src/commands/config/state.rs
index a503a0160..8cd876f1b 100644
--- a/src/commands/config/state.rs
+++ b/src/commands/config/state.rs
@@ -713,7 +713,7 @@ pub fn handle_state_get(
"default-branch" => {
let branch_name = repo.default_branch().ok_or_else(|| {
anyhow::anyhow!(cformat!(
- "Cannot determine default branch. To configure, run <bold>wt config state default-branch set BRANCH</>"
+ "Cannot determine default branch; to configure one, run <bold>wt config state default-branch set BRANCH</>"
))
})?;
println!("{branch_name}");
diff --git a/src/commands/step/promote.rs b/src/commands/step/promote.rs
index d1e664a13..225e9a9f8 100644
--- a/src/commands/step/promote.rs
+++ b/src/commands/step/promote.rs
@@ -251,7 +251,7 @@ fn print_promote_announcement(is_restoring: bool, default_branch: Option<&str>)
eprintln!(
"{}",
hint_message(cformat!(
- "Run <underline>wt step promote {default}</> to restore canonical locations"
+ "To restore canonical locations, run <underline>wt step promote {default}</>"
))
);
}
diff --git a/src/commands/step/relocate.rs b/src/commands/step/relocate.rs
index 75489115e..a993a8a1b 100644
--- a/src/commands/step/relocate.rs
+++ b/src/commands/step/relocate.rs
@@ -3,6 +3,7 @@
//! See `src/commands/relocate.rs` for the implementation details and algorithm.
use anyhow::Context;
+use color_print::cformat;
use std::path::PathBuf;
@@ -43,9 +44,9 @@ pub fn step_relocate(
// Validate default branch early - needed for main worktree relocation
if default_branch.is_empty() {
- anyhow::bail!(
- "Cannot determine default branch; set with: wt config state default-branch set main"
- );
+ anyhow::bail!(cformat!(
+ "Cannot determine default branch; to configure one, run <bold>wt config state default-branch set BRANCH</>"
+ ));
}
let repo_path = repo.repo_path()?.to_path_buf();
diff --git a/src/git/recover.rs b/src/git/recover.rs
index 75d4e68f3..18d72e896 100644
--- a/src/git/recover.rs
+++ b/src/git/recover.rs
@@ -75,10 +75,12 @@ fn hint_for_repo(repo: &Repository) -> String {
.flatten()
.is_some_and(|p| !repo.worktree_is_unusable(&p).unwrap_or(true))
{
- return cformat!("Current directory was removed. Try: <underline>wt switch ^</>");
+ return cformat!(
+ "Current directory was removed; to switch to the default branch, run <underline>wt switch ^</>"
+ );
}
- cformat!("Current directory was removed. Run <underline>wt list</> to see worktrees")
+ cformat!("Current directory was removed; to see worktrees, run <underline>wt list</>")
}
/// Attempt to recover a repository when the current directory has been deleted.
@@ -513,7 +515,7 @@ mod tests {
// A normal repo with a main worktree should suggest `wt switch ^`.
let test = TestRepo::with_initial_commit();
let hint = hint_for_repo(&test.repo);
- insta::assert_snapshot!(hint.ansi_strip(), @"Current directory was removed. Try: wt switch ^");
+ insta::assert_snapshot!(hint.ansi_strip(), @"Current directory was removed; to switch to the default branch, run wt switch ^");
}
#[test]
@@ -522,6 +524,6 @@ mod tests {
// so it should suggest `wt list` instead of `wt switch ^`.
let test = TestRepo::bare();
let hint = hint_for_repo(&test.repo);
- insta::assert_snapshot!(hint.ansi_strip(), @"Current directory was removed. Run wt list to see worktrees");
+ insta::assert_snapshot!(hint.ansi_strip(), @"Current directory was removed; to see worktrees, run wt list");
}
}
diff --git a/src/git/repository/config.rs b/src/git/repository/config.rs
index 862d14c04..f5d807a46 100644
--- a/src/git/repository/config.rs
+++ b/src/git/repository/config.rs
@@ -524,7 +524,7 @@ impl Repository {
.ok_or_else(|| {
GitError::Other {
message: cformat!(
- "Cannot determine default branch. Specify target explicitly or run <bold>wt config state default-branch set BRANCH</>"
+ "Cannot determine default branch; specify the target explicitly, or to configure one, run <bold>wt config state default-branch set BRANCH</>"
),
}
.into()
diff --git a/src/git/repository/worktrees.rs b/src/git/repository/worktrees.rs
index 827591b25..698edcf43 100644
--- a/src/git/repository/worktrees.rs
+++ b/src/git/repository/worktrees.rs
@@ -350,7 +350,7 @@ impl Repository {
self.switch_previous().ok_or_else(|| {
GitError::Other {
message: cformat!(
- "No previous branch found in history. Run <underline>wt list</> to see available worktrees."
+ "No previous branch found in history; to see available worktrees, run <bold>wt list</>"
),
}
.into()
@@ -359,7 +359,7 @@ impl Repository {
"^" => self.default_branch().ok_or_else(|| {
GitError::Other {
message: cformat!(
- "Cannot determine default branch. Specify target explicitly or run <underline>wt config state default-branch set <bold>BRANCH</></>"
+ "Cannot determine default branch; specify the target explicitly, or to configure one, run <bold>wt config state default-branch set BRANCH</>"
),
}
.into()
diff --git a/tests/integration_tests/config_state.rs b/tests/integration_tests/config_state.rs
index 471a6e77f..72a51f240 100644
--- a/tests/integration_tests/config_state.rs
+++ b/tests/integration_tests/config_state.rs
@@ -164,7 +164,7 @@ fn test_state_get_default_branch_fails_when_undetermined(repo: TestRepo) {
.output()
.unwrap();
assert!(!output.status.success());
- assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"✗ Cannot determine default branch. To configure, run wt config state default-branch set BRANCH");
+ assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"✗ Cannot determine default branch; to configure one, run wt config state default-branch set BRANCH");
}
#[rstest]
diff --git a/tests/snapshots/integration__integration_tests__step_promote__promote_from_worktree.snap b/tests/snapshots/integration__integration_tests__step_promote__promote_from_worktree.snap
index d39f1ba4c..18ee3c84d 100644
--- a/tests/snapshots/integration__integration_tests__step_promote__promote_from_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__step_promote__promote_from_worktree.snap
@@ -60,5 +60,5 @@ exit_code: 0
----- stderr -----
▲ Promoting creates mismatched worktree state (shown as ⚑ in wt list)
-↳ Run wt step promote main to restore canonical locations
+↳ To restore canonical locations, run wt step promote main
✓ Promoted: main worktree now has feature; _REPO_.feature now has main
diff --git a/tests/snapshots/integration__integration_tests__step_promote__promote_swap_bidirectional.snap b/tests/snapshots/integration__integration_tests__step_promote__promote_swap_bidirectional.snap
index 694723d57..731d46ec2 100644
--- a/tests/snapshots/integration__integration_tests__step_promote__promote_swap_bidirectional.snap
+++ b/tests/snapshots/integration__integration_tests__step_promote__promote_swap_bidirectional.snap
@@ -61,6 +61,6 @@ exit_code: 0
----- stderr -----
▲ Promoting creates mismatched worktree state (shown as ⚑ in wt list)
-↳ Run wt step promote main to restore canonical locations
+↳ To restore canonical locations, run wt step promote main
✓ Promoted: main worktree now has feature; _REPO_.feature now has main
✓ Swapped 4 gitignored paths
diff --git a/tests/snapshots/integration__integration_tests__step_promote__promote_swap_no_ignored_files.snap b/tests/snapshots/integration__integration_tests__step_promote__promote_swap_no_ignored_files.snap
index 8e25303b1..c078980c2 100644
--- a/tests/snapshots/integration__integration_tests__step_promote__promote_swap_no_ignored_files.snap
+++ b/tests/snapshots/integration__integration_tests__step_promote__promote_swap_no_ignored_files.snap
@@ -61,5 +61,5 @@ exit_code: 0
----- stderr -----
▲ Promoting creates mismatched worktree state (shown as ⚑ in wt list)
-↳ Run wt step promote main to restore canonical locations
+↳ To restore canonical locations, run wt step promote main
✓ Promoted: main worktree now has feature; _REPO_.feature now has main
diff --git a/tests/snapshots/integration__integration_tests__step_promote__promote_with_branch_argument.snap b/tests/snapshots/integration__integration_tests__step_promote__promote_with_branch_argument.snap
index 8e25303b1..c078980c2 100644
--- a/tests/snapshots/integration__integration_tests__step_promote__promote_with_branch_argument.snap
+++ b/tests/snapshots/integration__integration_tests__step_promote__promote_with_branch_argument.snap
@@ -61,5 +61,5 @@ exit_code: 0
----- stderr -----
▲ Promoting creates mismatched worktree state (shown as ⚑ in wt list)
-↳ Run wt step promote main to restore canonical locations
+↳ To restore canonical locations, run wt step promote main
✓ Promoted: main worktree now has feature; _REPO_.feature now has main
diff --git a/tests/snapshots/integration__integration_tests__step_relocate__relocate_empty_default_branch.snap b/tests/snapshots/integration__integration_tests__step_relocate__relocate_empty_default_branch.snap
index 5d3507c67..7d748c1bd 100644
--- a/tests/snapshots/integration__integration_tests__step_relocate__relocate_empty_default_branch.snap
+++ b/tests/snapshots/integration__integration_tests__step_relocate__relocate_empty_default_branch.snap
@@ -59,4 +59,4 @@ exit_code: 1
----- stdout -----
----- stderr -----
-✗ Cannot determine default branch; set with: wt config state default-branch set main
+✗ Cannot determine default branch; to configure one, run wt config state default-branch set BRANCH
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_no_history.snap b/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_no_history.snap
index 95ab5e65b..b6e0f93e2 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_no_history.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_no_history.snap
@@ -59,4 +59,4 @@ exit_code: 1
----- stdout -----
----- stderr -----
-✗ No previous branch found in history. Run wt list to see available worktrees.
+✗ No previous branch found in history; to see available worktrees, run wt list