Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: Display --execute command in switch output
Maximilian Roosc417ee6b7f67
diff --git a/src/output/handlers.rs b/src/output/handlers.rsindex 2f99fbd35..dcff26f77 100644--- a/src/output/handlers.rs+++ b/src/output/handlers.rs@@ -75,6 +75,8 @@ pub fn handle_switch_output(branch: &str,execute: Option<&str>,) -> Result<(), GitError> {+ use worktrunk::styling::{CYAN, format_with_gutter};+// Set target directory for command executionsuper::change_directory(result.path())?;@@ -83,6 +85,10 @@ pub fn handle_switch_output(// Execute command if providedif let Some(cmd) = execute {+ // Show what command is being executed (matches post-create/post-start format)+ super::progress(format!("π {CYAN}Executing (--execute):{CYAN:#}"))?;+ super::progress(format_with_gutter(cmd, "", None))?;+super::execute(cmd)?;} else {// No execute command: show shell integration hintdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_multiline_command_execution.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_multiline_command_execution.snapindex 3e9e7dc98..4dcf5d5dd 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_multiline_command_execution.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_multiline_command_execution.snap@@ -1,8 +1,11 @@---source: tests/integration_tests/shell_wrapper.rs-expression: normalized.as_ref()+expression: output.normalized().as_ref()---β [32mCreated new worktree for [1m[32mfish-multiline[0m at [TMPDIR]/test-repo.fish-multiline[0m+π [36mExecuting (--execute):[0m+[40m [0m echo 'line 1'; echo 'line 2'; echo 'line 3'+line 1line 2line 3diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_bash.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_bash.snapindex 9bb4c47c2..8bef55bb1 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_bash.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_bash.snap@@ -3,4 +3,7 @@ source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized().as_ref()---β [32mCreated new worktree for [1m[32mtest-exec[0m at [TMPDIR]/test-repo.test-exec[0m+π [36mExecuting (--execute):[0m+[40m [0m echo executed+executeddiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_fish.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_fish.snapindex 9bb4c47c2..8bef55bb1 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_fish.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_fish.snap@@ -3,4 +3,7 @@ source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized().as_ref()---β [32mCreated new worktree for [1m[32mtest-exec[0m at [TMPDIR]/test-repo.test-exec[0m+π [36mExecuting (--execute):[0m+[40m [0m echo executed+executeddiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_through_wrapper.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_through_wrapper.snapindex 301be4a41..8bef55bb1 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_through_wrapper.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_through_wrapper.snap@@ -1,6 +1,9 @@---source: tests/integration_tests/shell_wrapper.rs-expression: normalized.as_ref()+expression: output.normalized().as_ref()---β [32mCreated new worktree for [1m[32mtest-exec[0m at [TMPDIR]/test-repo.test-exec[0m+π [36mExecuting (--execute):[0m+[40m [0m echo executed+executeddiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap b/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snapindex febba510e..135e87bad 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap@@ -18,7 +18,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp78KaQw/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpE0F9E8/test-config.toml---success: trueexit_code: 0@@ -27,5 +27,8 @@ exit_code: 0[40m [0m echo 'Background task' > background.txtβ [32mCreated new worktree for [1m[32mfeature[0m at [REPO].feature[0m+π [36mExecuting (--execute):[0m+[40m [0m echo 'Execute flag' > execute.txt+----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__switch__switch_execute_creates_file.snap b/tests/snapshots/integration__integration_tests__switch__switch_execute_creates_file.snapindex a69027df0..2c4d8159d 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_execute_creates_file.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_execute_creates_file.snap@@ -18,11 +18,14 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpfuR0Av/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpnFxFGm/test-config.toml---success: trueexit_code: 0----- stdout -----β [32mCreated new worktree for [1m[32mfile-test[0m at [REPO].file-test[0m+π [36mExecuting (--execute):[0m+[40m [0m echo 'test content' > test.txt+----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__switch__switch_execute_existing.snap b/tests/snapshots/integration__integration_tests__switch__switch_execute_existing.snapindex 4aee16c41..0c97242a1 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_execute_existing.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_execute_existing.snap@@ -17,11 +17,14 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpG1OQqC/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpB10CRl/test-config.toml---success: trueexit_code: 0----- stdout -----β [32mSwitched to worktree for [1m[32mexisting-exec[0m at [WORKTREE_EXISTING_EXEC][0m+π [36mExecuting (--execute):[0m+[40m [0m echo 'existing worktree' > existing.txt+----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__switch__switch_execute_failure.snap b/tests/snapshots/integration__integration_tests__switch__switch_execute_failure.snapindex 8670c160a..08c8a0674 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_execute_failure.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_execute_failure.snap@@ -18,12 +18,15 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpnsD0ds/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpw4Og5c/test-config.toml---success: falseexit_code: 1----- stdout -----β [32mCreated new worktree for [1m[32mfail-test[0m at [REPO].fail-test[0m+π [36mExecuting (--execute):[0m+[40m [0m exit 1+----- stderr -----Command failed with exit code: exit status: 1diff --git a/tests/snapshots/integration__integration_tests__switch__switch_execute_multiline.snap b/tests/snapshots/integration__integration_tests__switch__switch_execute_multiline.snapindex 9023da248..d47966871 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_execute_multiline.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_execute_multiline.snap@@ -18,12 +18,17 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpcj4xNM/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp2CpQIq/test-config.toml---success: trueexit_code: 0----- stdout -----β [32mCreated new worktree for [1m[32mmultiline-test[0m at [REPO].multiline-test[0m+π [36mExecuting (--execute):[0m+[40m [0m echo 'line1'+[40m [0m echo 'line2'+[40m [0m echo 'line3'+----- stderr -----line1diff --git a/tests/snapshots/integration__integration_tests__switch__switch_execute_success.snap b/tests/snapshots/integration__integration_tests__switch__switch_execute_success.snapindex 61ea6b78d..6c21c03e3 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_execute_success.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_execute_success.snap@@ -18,12 +18,15 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmprttGVs/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpC1eteo/test-config.toml---success: trueexit_code: 0----- stdout -----β [32mCreated new worktree for [1m[32mexec-test[0m at [REPO].exec-test[0m+π [36mExecuting (--execute):[0m+[40m [0m echo 'test output'+----- stderr -----test outputdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_internal_with_execute.snap b/tests/snapshots/integration__integration_tests__switch__switch_internal_with_execute.snapindex 1754e8c85..5724099b4 100644Binary files a/tests/snapshots/integration__integration_tests__switch__switch_internal_with_execute.snap and b/tests/snapshots/integration__integration_tests__switch__switch_internal_with_execute.snap differdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_execute_still_runs.snap b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_execute_still_runs.snapindex b4bfca301..90fc5fd90 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_execute_still_runs.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_execute_still_runs.snap@@ -19,12 +19,15 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpd89MIY/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpzDqH7z/test-config.toml---success: trueexit_code: 0----- stdout -----β [32mCreated new worktree for [1m[32mno-hooks-test[0m at [REPO].no-hooks-test[0m+π [36mExecuting (--execute):[0m+[40m [0m echo 'execute command runs'+----- stderr -----execute command runsdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_existing.snap b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_existing.snapindex 723622449..25e0c3985 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_existing.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_existing.snap@@ -18,12 +18,15 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpjCYNYD/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpblVMRT/test-config.toml---success: trueexit_code: 0----- stdout -----β [32mSwitched to worktree for [1m[32mexisting-no-hooks[0m at [WORKTREE_EXISTING_NO_HOOKS][0m+π [36mExecuting (--execute):[0m+[40m [0m echo 'execute still runs'+----- stderr -----execute still runs