Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Add gutter to TOML config output
Maximilian Roos7efe417fd549
diff --git a/src/commands/config.rs b/src/commands/config.rsindex 2b26e932b..debd105f3 100644--- a/src/commands/config.rs+++ b/src/commands/config.rs@@ -92,7 +92,7 @@ fn display_global_config() -> Result<(), GitError> {}// Display TOML with syntax highlighting- print!("{}", format_toml(&contents, " "));+ print!("{}", format_toml(&contents, " "));Ok(())}@@ -130,7 +130,7 @@ fn display_project_config() -> Result<(), GitError> {}// Display TOML with syntax highlighting- print!("{}", format_toml(&contents, " "));+ print!("{}", format_toml(&contents, " "));Ok(())}diff --git a/src/styling.rs b/src/styling.rsindex a05ed6a14..00b12fc5e 100644--- a/src/styling.rs+++ b/src/styling.rs@@ -165,6 +165,9 @@ impl StyledLine {/// Formats TOML content with syntax highlighting using synopticpub fn format_toml(content: &str, indent: &str) -> String {+ // Gutter style: subtle background for visual separation+ let gutter = Style::new().bg_color(Some(Color::Ansi(AnsiColor::Black)));+// Get TOML highlighter from synoptic's built-in rules (tab_width = 4)let mut highlighter = match from_extension("toml", 4) {Some(h) => h,@@ -173,7 +176,7 @@ pub fn format_toml(content: &str, indent: &str) -> String {let dim = Style::new().dimmed();let mut output = String::new();for line in content.lines() {- output.push_str(&format!("{indent}{dim}{line}{dim:#}\n"));+ output.push_str(&format!("{gutter} {gutter:#}{indent}{dim}{line}{dim:#}\n"));}return output;}@@ -187,7 +190,9 @@ pub fn format_toml(content: &str, indent: &str) -> String {// Render each line with appropriate stylingfor (y, line) in lines.iter().enumerate() {- // Add indentation first+ // Add gutter first+ output.push_str(&format!("{gutter} {gutter:#}"));+ // Add indentationoutput.push_str(indent);// Render each token with appropriate styling@@ -265,7 +270,7 @@ project = "github.com/user/repo"command = "npm install""#;- let output = format_toml(toml_content, " ");+ let output = format_toml(toml_content, " ");// Check that output contains ANSI escape codesassert!(@@ -291,12 +296,16 @@ command = "npm install""Should contain cyan or bold for tables");- // Check indentation is preserved+ // Check that gutter background is present (Black background = 40)+ assert!(+ output.contains("\x1b[40m"),+ "Should contain gutter background color (Black = 40)"+ );++ // Check that lines have content (not just gutter)assert!(- output- .lines()- .all(|line| line.starts_with(" ") || line.is_empty()),- "All lines should be indented"+ output.lines().any(|line| line.len() > 20),+ "Should have lines with actual content beyond gutter and indent");}diff --git a/tests/snapshots/integration__integration_tests__config_list__config_list_no_project.snap b/tests/snapshots/integration__integration_tests__config_list__config_list_no_project.snapindex 3fd967f59..c568bffb7 100644--- a/tests/snapshots/integration__integration_tests__config_list__config_list_no_project.snap+++ b/tests/snapshots/integration__integration_tests__config_list__config_list_no_project.snap@@ -12,7 +12,7 @@ info:GIT_CONFIG_GLOBAL: /dev/nullGIT_CONFIG_SYSTEM: /dev/nullGIT_EDITOR: ""- HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpOhSuMo+ HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJLGPUBLANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1704067200"@@ -21,7 +21,7 @@ success: trueexit_code: 0----- stdout -----Global Config: [1m[TEMP_HOME]/.config/worktrunk/config.toml[0m- worktree-path = [32m"../{main-worktree}.{branch}"[0m+[40m [0m worktree-path = [32m"../{main-worktree}.{branch}"[0mProject Config: [1m[REPO]/.config/wt.toml[0m💡 [2mNot found[0mdiff --git a/tests/snapshots/integration__integration_tests__config_list__config_list_outside_repo.snap b/tests/snapshots/integration__integration_tests__config_list__config_list_outside_repo.snapindex aabadacc2..e8e934286 100644--- a/tests/snapshots/integration__integration_tests__config_list__config_list_outside_repo.snap+++ b/tests/snapshots/integration__integration_tests__config_list__config_list_outside_repo.snap@@ -6,7 +6,7 @@ info:- config- listenv:- HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpxHds55+ HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpfgWomq---success: trueexit_code: 0diff --git a/tests/snapshots/integration__integration_tests__config_list__config_list_with_project.snap b/tests/snapshots/integration__integration_tests__config_list__config_list_with_project.snapindex d348b0915..d94fbf043 100644--- a/tests/snapshots/integration__integration_tests__config_list__config_list_with_project.snap+++ b/tests/snapshots/integration__integration_tests__config_list__config_list_with_project.snap@@ -12,7 +12,7 @@ info:GIT_CONFIG_GLOBAL: /dev/nullGIT_CONFIG_SYSTEM: /dev/nullGIT_EDITOR: ""- HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp8ZWNvA+ HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpcA2FvPLANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1704067200"@@ -21,16 +21,16 @@ success: trueexit_code: 0----- stdout -----Global Config: [1m[TEMP_HOME]/.config/worktrunk/config.toml[0m- worktree-path = [32m"../{main-worktree}.{branch}"[0m-- [1m[36m[[approved-commands]][0m- project = [32m"test-project"[0m- command = [32m"npm install"[0m+[40m [0m worktree-path = [32m"../{main-worktree}.{branch}"[0m+[40m [0m+[40m [0m [1m[36m[[approved-commands]][0m+[40m [0m project = [32m"test-project"[0m+[40m [0m command = [32m"npm install"[0mProject Config: [1m[REPO]/.config/wt.toml[0m- post-create-command = [32m"npm install"[0m-- [1m[36m[post-start-command][0m- server = [32m"npm run dev"[0m+[40m [0m post-create-command = [32m"npm install"[0m+[40m [0m+[40m [0m [1m[36m[post-start-command][0m+[40m [0m server = [32m"npm run dev"[0m----- stderr -----