Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Fix: Remove `--execute` and `--internal` flag validation
Maximilian Roosc0a1c6b091d8
diff --git a/src/main.rs b/src/main.rsindex c2fd6f871..fb072215d 100644--- a/src/main.rs+++ b/src/main.rs@@ -185,35 +185,26 @@ fn main() {base,execute,internal,- } => {- // Validate that --execute is not used with --internal- if execute.is_some() && internal {- Err(GitError::CommandFailed(- "--execute flag cannot be used with --internal mode".to_string(),- ))- } else {- WorktrunkConfig::load()- .map_err(|e| GitError::CommandFailed(format!("Failed to load config: {}", e)))- .and_then(|config| {- handle_switch(- &branch,- create,- base.as_deref(),- execute.as_deref(),- &config,- )- .map(|result| {- if internal {- if let Some(output) = result.format_internal_output(&branch) {- println!("{}", output);- }- } else if let Some(output) = result.format_user_output(&branch) {- println!("{}", output);- }- })- })- }- }+ } => WorktrunkConfig::load()+ .map_err(|e| GitError::CommandFailed(format!("Failed to load config: {}", e)))+ .and_then(|config| {+ handle_switch(+ &branch,+ create,+ base.as_deref(),+ execute.as_deref(),+ &config,+ )+ .map(|result| {+ if internal {+ if let Some(output) = result.format_internal_output(&branch) {+ println!("{}", output);+ }+ } else if let Some(output) = result.format_user_output(&branch) {+ println!("{}", output);+ }+ })+ }),Commands::Remove { internal } => handle_remove().map(|result| {if internal {if let Some(output) = result.format_internal_output() {diff --git a/tests/integration_tests/switch.rs b/tests/integration_tests/switch.rsindex 904c47a76..574e2dbac 100644--- a/tests/integration_tests/switch.rs+++ b/tests/integration_tests/switch.rs@@ -173,21 +173,3 @@ fn test_switch_execute_with_existing_worktree() {&["existing-exec", "--execute", create_file_cmd],);}--#[test]-fn test_switch_execute_with_internal_error() {- let repo = TestRepo::new();- repo.commit("Initial commit");-- snapshot_switch(- "switch_execute_internal_error",- &repo,- &[- "--create",- "internal-test",- "--execute",- "echo test",- "--internal",- ],- );-}diff --git a/tests/snapshots/integration__integration_tests__switch__switch_execute_internal_error.snap b/tests/snapshots/integration__integration_tests__switch__switch_execute_internal_error.snapdeleted file mode 100644index ff9ac1f8a..000000000--- a/tests/snapshots/integration__integration_tests__switch__switch_execute_internal_error.snap+++ /dev/null@@ -1,28 +0,0 @@-----source: tests/integration_tests/switch.rs-info:- program: wt- args:- - switch- - "--create"- - internal-test- - "--execute"- - echo test- - "--internal"- env:- CLICOLOR_FORCE: "1"- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: /dev/null- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- LANG: C- LC_ALL: C- SOURCE_DATE_EPOCH: "1704067200"-----success: false-exit_code: 1------ stdout ------------ stderr --------execute flag cannot be used with --internal mode