Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: Add global `list` config options
Maximilian Roosf0572c98869e
diff --git a/config.example.toml b/config.example.tomlindex 6c5deea68..59ede5a94 100644--- a/config.example.toml+++ b/config.example.toml@@ -143,6 +143,12 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"# use a separate PROJECT config file at <repo>/.config/wt.toml# See: .config/wt.example.toml for project configuration examples+# List Command Defaults+# Configure default behavior for `wt list`+# [list]+# full = false # Show CI, conflicts, diffs by default+# branches = false # Include branches without worktrees by default+# Approved Commands# Commands approved for automatic execution after switching worktrees# Auto-populated when you use: wt switch --execute "command" --forcediff --git a/src/config/mod.rs b/src/config/mod.rsindex 0f647c9cd..aa5fd89fb 100644--- a/src/config/mod.rs+++ b/src/config/mod.rs@@ -76,6 +76,7 @@ mod tests {worktree_path: "{{ main_worktree }}.{{ branch }}".to_string(),commit_generation: CommitGenerationConfig::default(),projects: std::collections::BTreeMap::new(),+ list: None,};assert_eq!(config.format_path("myproject", "feature-x").unwrap(),@@ -89,6 +90,7 @@ mod tests {worktree_path: "{{ main_worktree }}-{{ branch }}".to_string(),commit_generation: CommitGenerationConfig::default(),projects: std::collections::BTreeMap::new(),+ list: None,};assert_eq!(config.format_path("myproject", "feature-x").unwrap(),@@ -102,6 +104,7 @@ mod tests {worktree_path: ".worktrees/{{ main_worktree }}/{{ branch }}".to_string(),commit_generation: CommitGenerationConfig::default(),projects: std::collections::BTreeMap::new(),+ list: None,};assert_eq!(config.format_path("myproject", "feature-x").unwrap(),@@ -116,6 +119,7 @@ mod tests {worktree_path: "{{ main_worktree }}.{{ branch }}".to_string(),commit_generation: CommitGenerationConfig::default(),projects: std::collections::BTreeMap::new(),+ list: None,};assert_eq!(config.format_path("myproject", "feature/foo").unwrap(),@@ -129,6 +133,7 @@ mod tests {worktree_path: ".worktrees/{{ main_worktree }}/{{ branch }}".to_string(),commit_generation: CommitGenerationConfig::default(),projects: std::collections::BTreeMap::new(),+ list: None,};assert_eq!(config.format_path("myproject", "feature/sub/task").unwrap(),@@ -143,6 +148,7 @@ mod tests {worktree_path: ".worktrees/{{ main_worktree }}/{{ branch }}".to_string(),commit_generation: CommitGenerationConfig::default(),projects: std::collections::BTreeMap::new(),+ list: None,};assert_eq!(config.format_path("myproject", "feature\\foo").unwrap(),@@ -405,15 +411,12 @@ task2 = "echo 'Task 2 running' > task2.txt"fn test_user_project_config_equality() {let config1 = UserProjectConfig {approved_commands: vec!["npm install".to_string()],- list: None,};let config2 = UserProjectConfig {approved_commands: vec!["npm install".to_string()],- list: None,};let config3 = UserProjectConfig {approved_commands: vec!["npm test".to_string()],- list: None,};assert_eq!(config1, config2);assert_ne!(config1, config3);@@ -426,7 +429,6 @@ task2 = "echo 'Task 2 running' > task2.txt""github.com/user/repo".to_string(),UserProjectConfig {approved_commands: vec!["npm install".to_string()],- list: None,},);diff --git a/src/config/user.rs b/src/config/user.rsindex 7836ae197..b7e8ba7fd 100644--- a/src/config/user.rs+++ b/src/config/user.rs@@ -62,6 +62,10 @@ pub struct WorktrunkConfig {/// Uses BTreeMap for deterministic serialization order and better diff readability#[serde(default)]pub projects: std::collections::BTreeMap<String, UserProjectConfig>,++ /// Configuration for the `wt list` command+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub list: Option<ListConfig>,}/// Configuration for commit message generation@@ -115,10 +119,6 @@ impl CommitGenerationConfig {/// ```toml/// [projects."github.com/user/repo"]/// approved-commands = ["npm install", "npm test"]-///-/// [projects."github.com/user/repo".list]-/// full = true-/// branches = false/// ```////// # Future Extensibility@@ -135,10 +135,6 @@ pub struct UserProjectConfig {skip_serializing_if = "Vec::is_empty")]pub approved_commands: Vec<String>,-- /// Configuration for the `wt list` command- #[serde(default, skip_serializing_if = "Option::is_none")]- pub list: Option<ListConfig>,}/// Configuration for the `wt list` command@@ -159,6 +155,7 @@ impl Default for WorktrunkConfig {worktree_path: "../{{ main_worktree }}.{{ branch }}".to_string(),commit_generation: CommitGenerationConfig::default(),projects: std::collections::BTreeMap::new(),+ list: None,}}}diff --git a/src/main.rs b/src/main.rsindex 2664ed690..6cf6bdb11 100644--- a/src/main.rs+++ b/src/main.rs@@ -277,20 +277,11 @@ fn main() {WorktrunkConfig::load().context("Failed to load config").and_then(|config| {- let repo = Repository::current();-- // Get config values if we can determine the project ID- // If we can't (e.g., early in initialization), use defaults- let (show_branches_config, show_full_config) = repo- .project_identifier()- .ok()- .and_then(|project_id| {- config.projects.get(&project_id).and_then(|p| {- p.list- .as_ref()- .map(|l| (l.branches.unwrap_or(false), l.full.unwrap_or(false)))- })- })+ // Get config values from global list config+ let (show_branches_config, show_full_config) = config+ .list+ .as_ref()+ .map(|l| (l.branches.unwrap_or(false), l.full.unwrap_or(false))).unwrap_or((false, false));// CLI flags override config