From 38d0437489ec77c9862c973ab279a72f01bbaef3 Mon Sep 17 00:00:00 2001 From: Dennis Doomen Date: Sat, 18 Jul 2026 13:21:05 +0200 Subject: [PATCH] Style fallout-migrate's banner and summary output with AnsiConsole Replace the plain Console.WriteLine calls in MigrateCommand's banner and summary printing with Spectre.Console's AnsiConsole: bold banner, yellow dry-run notice and warnings, green completion messages, dimmed guide link. Interpolated values (paths, warning text) go through MarkupLineInterpolated so user-controlled content can't be misinterpreted as markup. Left Console.Error.WriteLine for the two error messages (stderr semantics matter for piping/exit codes) and the TextWriter-based per-file/per-rename logging in the Steps/Common classes untouched -- that log stays plain text so MigrationIntegrationSpecs can keep capturing it via TextWriter.Null without a console. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/Fallout.Migrate/MigrateCommand.cs | 31 ++++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Fallout.Migrate/MigrateCommand.cs b/src/Fallout.Migrate/MigrateCommand.cs index f4064ab01..83f35e82b 100644 --- a/src/Fallout.Migrate/MigrateCommand.cs +++ b/src/Fallout.Migrate/MigrateCommand.cs @@ -5,6 +5,7 @@ using Fallout.Common.IO; using Fallout.Migrate.Common; using JetBrains.Annotations; +using Spectre.Console; using Spectre.Console.Cli; namespace Fallout.Migrate; @@ -83,13 +84,13 @@ private static AbsolutePath ResolveRootDirectory(string explicitArg) /// Whether the migration is running in dry-run mode. private static void PrintBanner(AbsolutePath rootDirectory, bool dryRun) { - Console.WriteLine($"fallout-migrate — migrating: {rootDirectory}"); + AnsiConsole.MarkupLineInterpolated($"[bold]fallout-migrate[/] — migrating: [blue]{rootDirectory}[/]"); if (dryRun) { - Console.WriteLine("(dry-run — no files will be modified)"); + AnsiConsole.MarkupLine("[yellow](dry-run — no files will be modified)[/]"); } - Console.WriteLine(); + AnsiConsole.WriteLine(); } /// @@ -99,26 +100,26 @@ private static void PrintBanner(AbsolutePath rootDirectory, bool dryRun) /// Whether the migration ran in dry-run mode. private static void PrintSummary(Summary summary, bool dryRun) { - Console.WriteLine(); - Console.WriteLine($"Files changed: {summary.FilesChanged}"); - Console.WriteLine($"Edits made: {summary.EditCount}"); - Console.WriteLine($"Directories: {summary.DirectoriesRenamed} renamed"); + AnsiConsole.WriteLine(); + AnsiConsole.MarkupLineInterpolated($"Files changed: [bold]{summary.FilesChanged}[/]"); + AnsiConsole.MarkupLineInterpolated($"Edits made: [bold]{summary.EditCount}[/]"); + AnsiConsole.MarkupLineInterpolated($"Directories: [bold]{summary.DirectoriesRenamed}[/] renamed"); if (summary.Warnings.Count > 0) { - Console.WriteLine(); - Console.WriteLine("Warnings:"); + AnsiConsole.WriteLine(); + AnsiConsole.MarkupLine("[yellow]Warnings:[/]"); foreach (var w in summary.Warnings) { - Console.WriteLine($" - {w}"); + AnsiConsole.MarkupLineInterpolated($"[yellow] - {w}[/]"); } } - Console.WriteLine(); - Console.WriteLine(dryRun - ? "Dry-run complete. Re-run without --dry-run to apply changes." - : "Migration complete. Verify the build: ./build.ps1 (or ./build.sh on UNIX)"); + AnsiConsole.WriteLine(); + AnsiConsole.MarkupLine(dryRun + ? "[green]Dry-run complete.[/] Re-run without --dry-run to apply changes." + : "[green]Migration complete.[/] Verify the build: ./build.ps1 (or ./build.sh on UNIX)"); - Console.WriteLine("Migration guide: https://fallout.build (see #37 for the full guide)"); + AnsiConsole.MarkupLine("[grey]Migration guide: https://fallout.build (see #37 for the full guide)[/]"); } }