Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Fix pager for config show --full, unify diagnostics output (#198)
Maximilian Roosee5ae25aceef
diff --git a/src/commands/config.rs b/src/commands/config.rsindex a00f9c043..2036c5dcd 100644--- a/src/commands/config.rs+++ b/src/commands/config.rs@@ -132,29 +132,27 @@ pub fn handle_config_show(full: bool) -> anyhow::Result<()> {// Render shell integration statusrender_shell_status(&mut show_output)?;- // Display through pager (only if not in full mode, since full adds interactive output)+ // Run full diagnostic checks if requested (includes slow network calls)if full {- worktrunk::styling::eprintln!("{}", show_output);- } else if let Err(e) = show_help_in_pager(&show_output) {+ show_output.push('\n');+ render_diagnostics(&mut show_output)?;+ }++ // Display through pager+ if let Err(e) = show_help_in_pager(&show_output) {log::debug!("Pager invocation failed: {}", e);// Fall back to direct output via eprintln (matches help behavior)worktrunk::styling::eprintln!("{}", show_output);}- // Run full diagnostic checks if requested (includes slow network calls)- if full {- output::blank()?;- run_diagnostics()?;- }-Ok(())}-/// Run full diagnostic checks (CI tools, commit generation)-fn run_diagnostics() -> anyhow::Result<()> {+/// Run full diagnostic checks (CI tools, commit generation) and render to buffer+fn render_diagnostics(out: &mut String) -> anyhow::Result<()> {use super::list::ci_status::{CiPlatform, CiToolsStatus, get_platform_for_repo};- output::heading("DIAGNOSTICS", None)?;+ writeln!(out, "{}", format_heading("DIAGNOSTICS", None))?;// Check CI tool based on detected platformlet platform = Repository::current()@@ -166,6 +164,7 @@ fn run_diagnostics() -> anyhow::Result<()> {Some(CiPlatform::GitHub) => {let ci_tools = CiToolsStatus::detect(None);render_ci_tool_status(+ out,"gh","GitHub",ci_tools.gh_installed,@@ -175,6 +174,7 @@ fn run_diagnostics() -> anyhow::Result<()> {Some(CiPlatform::GitLab) => {let ci_tools = CiToolsStatus::detect(None);render_ci_tool_status(+ out,"glab","GitLab",ci_tools.glab_installed,@@ -182,7 +182,11 @@ fn run_diagnostics() -> anyhow::Result<()> {)?;}None => {- output::print(hint_message("CI status requires GitHub or GitLab remote"))?;+ writeln!(+ out,+ "{}",+ hint_message("CI status requires GitHub or GitLab remote")+ )?;}}@@ -191,7 +195,7 @@ fn run_diagnostics() -> anyhow::Result<()> {let commit_config = &config.commit_generation;if !commit_config.is_configured() {- output::print(hint_message("Commit generation not configured"))?;+ writeln!(out, "{}", hint_message("Commit generation not configured"))?;return Ok(());}@@ -207,16 +211,24 @@ fn run_diagnostics() -> anyhow::Result<()> {match test_commit_generation(commit_config) {Ok(message) => {- output::print(success_message(cformat!(- "Commit generation working (<bold>{command_display}</>)"- )))?;- output::gutter(format_with_gutter(&message, "", None))?;+ writeln!(+ out,+ "{}",+ success_message(cformat!(+ "Commit generation working (<bold>{command_display}</>)"+ ))+ )?;+ write!(out, "{}", format_with_gutter(&message, "", None))?;}Err(e) => {- output::print(error_message(cformat!(- "Commit generation failed (<bold>{command_display}</>)"- )))?;- output::gutter(format_with_gutter(&e.to_string(), "", None))?;+ writeln!(+ out,+ "{}",+ error_message(cformat!(+ "Commit generation failed (<bold>{command_display}</>)"+ ))+ )?;+ write!(out, "{}", format_with_gutter(&e.to_string(), "", None))?;}}@@ -448,6 +460,7 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {}fn render_ci_tool_status(+ out: &mut String,tool: &str,platform: &str,installed: bool,@@ -455,18 +468,28 @@ fn render_ci_tool_status() -> anyhow::Result<()> {if installed {if authenticated {- output::print(info_message(cformat!(- "<bold>{tool}</> installed & authenticated"- )))?;+ writeln!(+ out,+ "{}",+ success_message(cformat!("<bold>{tool}</> installed & authenticated"))+ )?;} else {- output::print(warning_message(cformat!(- "<bold>{tool}</> installed but not authenticated; run <bright-black>{tool} auth login</>"- )))?;+ writeln!(+ out,+ "{}",+ warning_message(cformat!(+ "<bold>{tool}</> installed but not authenticated; run <bright-black>{tool} auth login</>"+ ))+ )?;}} else {- output::print(hint_message(cformat!(- "<bold>{tool}</> not found ({platform} CI status unavailable)"- )))?;+ writeln!(+ out,+ "{}",+ hint_message(cformat!(+ "<bold>{tool}</> not found ({platform} CI status unavailable)"+ ))+ )?;}Ok(())}diff --git a/src/output/global.rs b/src/output/global.rsindex cd7dfb9a3..b365bf03c 100644--- a/src/output/global.rs+++ b/src/output/global.rs@@ -168,22 +168,6 @@ pub fn table(content: impl Into<String>) -> io::Result<()> {stderr().flush()}-/// Output a section heading (cyan uppercase text, no emoji)-///-/// Used for organizing output into distinct sections (e.g., `wt config show`, `wt state show`).-/// Section headings are visual separators, not status messages.-///-/// # Example-/// ```rust,ignore-/// output::heading("BINARIES", None)?;-/// output::heading("USER CONFIG", Some("~/.config/wt.toml"))?;-/// ```-pub fn heading(title: &str, suffix: Option<&str>) -> io::Result<()> {- use worktrunk::styling::format_heading;- eprintln!("{}", format_heading(title, suffix));- stderr().flush()-}-/// Request directory change (for shell integration)////// In directive mode, buffers the path for the final shell script.diff --git a/src/output/mod.rs b/src/output/mod.rsindex 970f730a9..83fea126b 100644--- a/src/output/mod.rs+++ b/src/output/mod.rs@@ -55,7 +55,7 @@ pub mod handlers;// Re-export the public APIpub use global::{OutputMode, blank, change_directory, data, execute, flush, flush_for_stderr_prompt, gutter,- heading, initialize, print, shell_integration_hint, table, terminate_output,+ initialize, print, shell_integration_hint, table, terminate_output,};// Re-export output handlerspub use handlers::{diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snapindex 71b47e0c2..455a8b0c1 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap@@ -44,7 +44,6 @@ exit_code: 0βͺ [2mSkipped zsh; ~/.zshrc not found[22mβͺ [2mSkipped fish; ~/.config/fish/conf.d not found[22m-[36mDIAGNOSTICS[39mπ‘ [2mCI status requires GitHub or GitLab remote[22mβ [31mCommit generation failed ([1mnonexistent-llm-command-12345 -m test-model[22m)[39mdiff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snapindex 28e3912b7..641fa8651 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap@@ -40,7 +40,6 @@ exit_code: 0βͺ [2mSkipped zsh; ~/.zshrc not found[22mβͺ [2mSkipped fish; ~/.config/fish/conf.d not found[22m-[36mDIAGNOSTICS[39mπ‘ [2mCI status requires GitHub or GitLab remote[22mπ‘ [2mCommit generation not configured[22m