From 1a5df7e687238f0873854ceef6c6a4172c0138b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Sat, 9 May 2026 00:13:58 +0200 Subject: [PATCH] =?UTF-8?q?Ensure=20that=20"The=20value=20'=E2=80=A6'=20is?= =?UTF-8?q?=20not=20in=20a=20correct=20format"=20ends=20with=20a=20new=20l?= =?UTF-8?q?ine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's weird when an error message doesn't have a newline in a CLI app. Note that all other CommandParseException exceptions created through CommandLineParseExceptionFactory are properly ended with a new line. --- src/Spectre.Console.Cli.Tests/CommandAppTests.Pairs.cs | 4 ++-- src/Spectre.Console.Cli/CommandParseException.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Spectre.Console.Cli.Tests/CommandAppTests.Pairs.cs b/src/Spectre.Console.Cli.Tests/CommandAppTests.Pairs.cs index a9e2435..1d064e6 100644 --- a/src/Spectre.Console.Cli.Tests/CommandAppTests.Pairs.cs +++ b/src/Spectre.Console.Cli.Tests/CommandAppTests.Pairs.cs @@ -192,7 +192,7 @@ public void Should_Throw_If_Value_Is_Not_In_A_Valid_Format_Using_Default_Deconst string input, string expected) { // Given - var app = new CommandAppTester(); + var app = new CommandAppTester { TestSettings = { TrimConsoleOutput = false } }; app.SetDefaultCommand>(); // When @@ -203,7 +203,7 @@ public void Should_Throw_If_Value_Is_Not_In_A_Valid_Format_Using_Default_Deconst // Then result.ExitCode.ShouldBe(-1); - result.Output.ShouldBe(expected); + result.Output.ShouldBe(expected + Environment.NewLine); } [Fact] diff --git a/src/Spectre.Console.Cli/CommandParseException.cs b/src/Spectre.Console.Cli/CommandParseException.cs index 19c0518..59f3146 100644 --- a/src/Spectre.Console.Cli/CommandParseException.cs +++ b/src/Spectre.Console.Cli/CommandParseException.cs @@ -110,7 +110,7 @@ internal static CommandParseException UnknownOption(IEnumerable args, Co internal static CommandParseException ValueIsNotInValidFormat(string value) { - var text = $"[red]Error:[/] The value '[white]{value}[/]' is not in a correct format"; + var text = $"[red]Error:[/] The value '[white]{value}[/]' is not in a correct format{Environment.NewLine}"; return new CommandParseException("Could not parse value", new Markup(text)); }