From 5cb1c9e0409d88a94b4cdb34a0e91bf42a74aa34 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:10:49 -0700 Subject: [PATCH] fix(buildtool): render --check-prereqs through Spectre like everything else MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The flag printed its own Console.WriteLine table while the guided menu rendered the same PrerequisiteResult list through PrerequisiteChecker. Two renderers for one result set, free to drift, and only one of them carried the tool's branding. Call the existing one and delete the duplicate. Spectre drops ANSI styling on its own when stdout is not a terminal, which is the case this flag exists for, so redirected output stays clean. It also falls back to an 80 column width and folds past it, which matters here because the warnings are shell commands meant to be copied — the CentOS EPEL hint is 95 characters and would have gained a newline mid-command. Widen the profile when output is redirected. Exit codes are unchanged: 0 when everything resolves, 1 when anything is missing. --- Projects/BuildTool/Program.cs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Projects/BuildTool/Program.cs b/Projects/BuildTool/Program.cs index dd2b16479..915839bbf 100644 --- a/Projects/BuildTool/Program.cs +++ b/Projects/BuildTool/Program.cs @@ -4,6 +4,7 @@ using BuildTool.Interactive; using BuildTool.Platform; using BuildTool.Prerequisites; using BuildTool.Publishing; +using Spectre.Console; Console.OutputEncoding = Encoding.UTF8; @@ -38,25 +39,18 @@ var rid = $"{options.Os}-{options.Arch}"; if (options.CheckPrereqsOnly) { - var allPassed = true; - - foreach (var result in NativeLibraryChecker.Check(detectedPlatform)) + // Same renderer the guided menu uses, so the two cannot drift. Spectre drops ANSI styling by + // itself when stdout is not a terminal, which is the case this flag exists for, but it also + // falls back to an 80 column width and folds anything longer. The install hints we print are + // shell commands — the CentOS one is 95 characters — and a fold puts a newline in the middle of + // a command that someone is meant to copy. Widen the profile so they stay on one line. + if (Console.IsOutputRedirected) { - if (!result.IsWarning) - { - Console.WriteLine($"{result.Name,-16} {(result.Passed ? "OK" : "MISSING"),-8} {result.Details}"); - allPassed &= result.Passed; - continue; - } - - Console.WriteLine(result.Details); - if (result.InstallCommand is not null) - { - Console.WriteLine($" {result.InstallCommand}"); - } + AnsiConsole.Profile.Width = 200; } - return allPassed ? 0 : 1; + // Exit code is the machine-readable half: 0 when everything resolves, 1 when anything is missing. + return PrerequisiteChecker.CheckNativeLibraries(detectedPlatform, interactive: false) ? 0 : 1; } // Run prerequisite checks unless skipped